Updating statistics in sql server 2016 dorsetadultdating com
If you care about SQL Server performance you need to take SQL Server Statistics into account.Statistics are lightweight and small objects which describe how data in SQL Server tables are distributed.The query optimizer uses them to create query plans that improve query performance.If you have AUTO_UPDATE_STATISTICS option turned on for the database the query optimizer will automatically determine when statistics might be out-of-date and then update them when they are used by a query.SQL Server has pre-determined thresholds where it considers statistics to be out-of-date and therefore invalid.The technical article, Statistics Used by the Query Optimizer in Microsoft SQL Server 2008, documents these thresholds.If they are, then the automatic update of those statistics occurs.If a plan does not exist in cache for a query, then if the optimizer uses a statistics object that is out of date when the plan compiles, SQL Server will automatically update those statistics.
During the PASS Summit in November I presented a session on Demystifying Database Statistics (if you attended Summit but missed it, you can stream it from here).
The number of rows added via the bulk import was just over the limit to trigger an auto-update of statistics for the next query, which I showed.
I had many people ask why statistics did not update immediately after the bulk load of the 25,000 rows completed, so I want to step through the demo that I did at Summit to clarify when an automatic update will occur.
But you need to when the automatic update does not occur frequently enough to provide you with a proper set of statistics or because the sampled nature of the automatic updates is causing your statistics to be inaccurate.
Note, though, that updating statistics causes queries to recompile and experienced users recommend not to update statistic too often.