T/F: Using IF statements in a procedure produces multiple plans

前端 未结 4 1713
轮回少年
轮回少年 2021-01-01 04:53

In responses to this question, KM said

if you are on or above SQL Server 2005, you can use IFs to have multiple queries in the same procedure and each

4条回答
  •  渐次进展
    2021-01-01 05:17

    We're all correct :-)

    • A "query plan" has at most 2 entries in cache: one serial and one parallel

    • Each user has their own "Execution context" that runs the plan

    • Plans differ if objects are not qualified

    So, what you may think is a plan is not because tables are not qualified with schema (which is the same in SQL Server 2000 , 2005 and 2008)

    From MSDN/BOL "Execution Plan Caching and Reuse"

    Edit:

    "Obtaining Statement-Level Query Plans" from MS blog

提交回复
热议问题