SQL-Server Performance: What is faster, a stored procedure or a view?

后端 未结 11 672
星月不相逢
星月不相逢 2020-12-04 23:53

What is faster in SQL Server 2005/2008, a Stored Procedure or a View?

EDIT: As many of you pointed out, I am being too vague. Let me attempt to

11条回答
  •  执笔经年
    2020-12-05 00:22

    A couple other considerations: While performance between an SP and a view are essentially the same (given they are performing the exact same select), the SP gives you more flexibility for that same query.

    • The SP will support ordering the result set; i.e., including an ORDER BY statement. You cannot do so in a view.
    • The SP is fully compiled and requires only an exec to invoke it. The view still requires a SELECT * FROM view to invoke it; i.e., a select on the compiled select in the view.

提交回复
热议问题