Query Recompilation

  • Grant Fritchey


Stored procedures and parameterized queries improve the reusability of an execution plan by explicitly converting the variable parts of the queries into parameters. This allows execution plans to be reused when the queries are resubmitted with the same or different values for the variable parts. Since stored procedures are mostly used to implement complex business rules, a typical stored procedure contains a complex set of SQL statements, making the price of generating the execution plan of the queries within a stored procedure a bit costly. Therefore, it is usually beneficial to reuse the existing execution plan of a stored procedure instead of generating a new plan. However, sometimes the existing plan may not be optimal, or it may not provide the best processing strategy during reuse. SQL Server resolves this condition by recompiling statements within stored procedures to generate a new execution plan. This chapter covers the following topics:
  • The benefits and drawbacks of recompilation

  • How to identify the statements causing recompilation

  • How to analyze the causes of recompilations

  • Ways to avoid recompilations when necessary


Execution Plan Select Statement Table Variable Query Plan Temporary Table 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Grant Fritchey 2012

Authors and Affiliations

  • Grant Fritchey

There are no affiliations available

Personalised recommendations