SQL server deletes all execution plans when SQL service is restarted. Is there any way these can be saved before we restart the service?
SQL server deletes all execution plans when SQL service is restarted. Is there any
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
The closest thing you can provide is plan guides, but even with plan guides the server will have to recompile every query the first time it is submitted after the restart. Plan guides can theoretically reduce the amount of work required during query compilation.
As Martin suggested, you can pull information out about the query plans, if you want to do analysis, but you can’t put that information back in later:
SELECT query_plan FROM sys.dm_exec_cached_plans CROSS APPLY sys.dm_exec_query_plan(plan_handle)If you are truly concerned, then set up a suite of queries to run after a service restart that will populate the plan cache. But I think that is a waste of time.
The mere fact that the SQL Server service will be down means that users will experience an outage. This already requires planning and communication. Understanding that such a restart’s effects have a larger scope than merely the denial of service during the restart time–the first few minutes of usage may be slow–simply changes your planning and communication by a bit. If some kind of theoretical slowness is a big problem, you’ll have to plan the downtime more carefully or wait for a more opportune time–2am instead of 2pm perhaps.
I say “theoretical slowness” because no one may experience any true issue with recompiling queries afterward. Queries generally compile very quickly.