Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to drop sql statistics?

Tags:

We've been trying to alter a lot of columns from nullable to not nullable, which involves dropping all the associated objects, making the change, and recreating the associated objects.

We've been using SQL Compare to generate the scripts, but I noticed that SQL Compare doesn't script statistic objects. Does this mean its ok to drop them and the database will work as well as it did before without them, or have Red Gate missed a trick?

like image 357
mcintyre321 Avatar asked Aug 21 '08 16:08

mcintyre321


2 Answers

It is considered best practice to auto create and auto update statistics. Sql Server will create them if it needs them. You will often see the tuning wizard generate lots of these, and you will also see people advise that you update statistics as a part of your maintenance plan, but this is not necessary and might actually make things worse, just so long as auto create and auto update are enabled.

like image 165
Eric Z Beard Avatar answered Sep 30 '22 18:09

Eric Z Beard


If you have update stats and auto create stats on then it should works as before You can also run sp_updatestats or UPDATE STATISTICS WITH FULLSCAN after you make the changes

like image 32
SQLMenace Avatar answered Sep 30 '22 19:09

SQLMenace