The update statistics command
helps the server make the best decisions about which indexes to use when
it processes a query, by providing information about the distribution of the
key values in the indexes.
The update statistics commands
create statistics, if there are no statistics for a particular column, or
replaces existing statistics if they already exist.
The statistics are stored in the system
tables systabstats and sysstatistics.
- update
statistics <table> - Generates
statistics for the leading column in each index on the table.
- update
statistics <table> <index> - Generates
statistics for all columns of the index
- update
index statistics <table> - Generates
statistics for all columns in all indexes on the table.
- update all statistics <table> - Generates statistics for all columns of a table.