When SQL server run same query second time than does SQL server generate execution plan again or use execution plan that is stored in cache memory? [duplicate]

h6my8fg2  于 2023-04-04  发布在  SQL Server
关注(0)|答案(1)|浏览(176)

This question already has answers here:

What factors can cause Stored Procedure Recompilation on SQL Server? (3 answers)
When does a Stored Procedure recompile?(Sql Server) (3 answers)

Closed 6 days ago.

I am exploring performance tuning in SQL server and found that in SQL server best execution plan and statistics of query is stored in cache memory so just want to know that,

when SQL server run same query second time than does SQL server generate execution plan again or use execution plan that is stored in cache memory ?

If both possible than based on which criteria SQL server will decide what to do recompile or use stored execution plan ?

sgtfey8w

sgtfey8w1#

According to this article :
The duration that a query plan stays in the plan cache depends upon how often a query is executed. Query plans that are used more often, stay in the query plan cache for longer durations, and vice-versa.

相关问题