Do SQL Server statistics get updated during a restore–is this a myth?

I have heard this from a couple of sources but never found any solid documentation to support it.   Does the restore process contain some mechanism to update statistics?  On the one hand restore will upgrade a database so it seems reasonable from that standpoint.  But if it did update stats you would think Microsoft would add a parameter to turn it on or off.  Add to that experts like Paul Randall repeatedly state that a backup is an exact copy of the database at the point of backup and this starts to smell like a myth.  So let’s see if it is true or not.

 

Let’s look at the statistics of AdventureWorks2008 before taking any action.  To narrow things down let’s look at the DatabaseLog table in particular.

image

Now let’s update the statistics by running sp_updatestats and take another look.

image

As you can see the statistics have been updated for the primary key on that table.  Now let’s restore from a backup made prior to updating the

statistics and see what happens.

image

 

The statistics post restore have returned to the original state.  Based on this experiment this can be put in the myth category.

Advertisements
This entry was posted in Database Administration and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s