Is querying over a view slower than executing SQL directly?

后端 未结 2 1975
孤城傲影
孤城傲影 2021-01-17 13:11

Scenario:

I have 3 tables needing to be joined together, a where clause to limit the result set, and only a few columns from each table being selected. Simple. Howev

2条回答
  •  别那么骄傲
    2021-01-17 13:54

    From MSDN: View resolution

    When an SQL statement references a nonindexed view, the parser and query optimizer analyze the source of both the SQL statement and the view and then resolve them into a single execution plan. There is not one plan for the SQL statement and a separate plan for the view.

    There should not be any different performance. Views helps you organize, not any performance enhancement. Unless you are using indexed views.

    Only the definition of a nonindexed view is stored, not the rows of the view. The query optimizer incorporates the logic from the view definition into the execution plan it builds for the SQL statement that references the nonindexed view.

提交回复
热议问题