question

avakharia avatar image
avakharia asked

SQL Server 2008 R2 Restart and its side effects

Can anyone tell me what happens to the executions plans/procedure cache/table statistics when the Server restarts (windows server not just the sql service)? Database size is over 250 GB. Next time you visit your site, will the DB operation be slow because server restart clears out the procedure cache or query plans (if it does)? I just want to get some insight in to what or if anything is affected when the server is restarted and if there are any solutions to preventing or solving them when it comes back online.
sql-server-2008-r2
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JohnM avatar image
JohnM answered
If memory serves, the execution plan & procedure cache are cleared on a restart. If you are referring to the statistics (the physical object), that is NOT cleared. However, statistics about the table/index contained in the DMV's are also cleared. There are a number of things that occur when SQL Server starts up that could slow it down, such as the time it takes to rollback/rollforward from the transaction log if the transaction log is unusually large or having a cold cache. Does the database speed up after a bit from when the initial connections? One solution that I've heard about but never implemented myself is having a process to call all the related stored procedures before the server is open for client connections. This would force the server to warm up the cache so that the overhead of creating the query plan & cache are done before the client gets to the web site. I don't know how effective this method is, but it's one that I've seen. Are you sure the slowness is related to a cold cache? What have you investigated? Is it just this one database or do you have 500 other databases on the same system? Without knowing more about the situation or what you're seeing, it'll be difficult to determine if the slowness is related to a cold cache or something else. Hope this helps!!
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avakharia avatar image
avakharia answered
Thanks John. I've also heard about the warm up idea of caching once the server restarts and before getting the client connections. This is just for to know and figure out what to expect when the server restarts. I do have multiple databases but not yet even in double digits. Only one of them is a big database, all of the rest are in MB's. I'm all about performance, so I tend to look in to ways I can optimize SQL and the server which would help serve users fast. Do you have any reference to MS technet article or someone else who has managed to research on this topic?
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JohnM avatar image JohnM commented ·
Just out of sheer curiosity, have you ever check for what the WAIT_STATS say during that slowness just after a restart?
0 Likes 0 ·
avakharia avatar image avakharia commented ·
I have not checked after the restart but I'll when I restart next time.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.