Update Statistics in SQL Server16-03-2019 0 Comment(s)
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. But you need to update your statistics manually 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. All you need to do is to find the middle ground between the time it takes to recompile queries and improving query plans.
USE AdventureWorks; GO UPDATE STATISTICS Adventureworks.<table_name> <index_name>; GO
No Comments to Show