Creating and maintaining statistics
SQL Server's Query Optimizer uses statistics to create query plans that improve query performance. Statistics contain statistical information regarding the distribution of values in one or more columns of a table or indexed view. The Query Optimizer uses statistical information to determine the number of rows in a query result, which enables the Query Optimizer to determine an optimal query plan. As such, up-to-date statistics are crucial for generating an optimal query plan and to ensure excellent performance.
Automatically managing statistics
The SQL Server Query Optimizer will automatically create statistics in two different ways:
- When an index is created, the Query Optimizer will create statistics on the key column(s) of the index.
- The Query Optimizer will create statistics in query predicates when the
AUTO_CREATE_STATISTICS
option is set toON
.
But there are three options that can be set to determine when statistics...