Sql-server – Should SQL Server statistics be included in versioning

database-tuning-advisorsql serverstatistics

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?

Best Answer

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.