Recently I ran the SQL Server Tuning Advisor. It suggested to add some statistics. Currently we have no statistics checked in our database versioning.

My question is: Should these suggested statistics be added to the versioning (like SVN or git)?

I am not sure this is a good idea, because they were created based on the usage of this particular database server. The alternative I currently like better is to run the Tuning Advisor on each server separatly, add the statistics and don't include them in schema compares.

What are the best practices? What are your negative/positive experiences?

  • The better idea is to investigate and create appropriate indexes, and store those index definitions like any other piece of code...stored proc, table def, etc. Stats will get created along with the indexes and are dependent on the data – Kevin3NF Jul 30 '18 at 11:45

If I am manually creating statistics then yes I would source control those, like I would any other database object. That way if I roll out a fresh environment from source I know it has everything required to function.

Why would I create manual statistics? Well I’d do this if I need control over the maintenance of them, for example if I am using table partitioning then I will manually create statistics and set them to incremental build and with no recompute. This way I can update the statistics manually as part of my ETL, just after I have switched in a new partition of data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.