Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

The stored procedure sp_show_statistics displays the current distribution statistics for the specified table and index, or for all tables and indexes.



sp_show_statistics [ 'table_name' ] , [ 'index_name' ]
table_name

The name of the table for which you want to display statistics. If you do not specify a table name, the statistics for all tables and indexes in the database are returned.

index_name

The name of the index on which you want statistics. If you do not specify an index name, all indexes in the specified table are returned.

The following table describes the columns returned in the result set.

Column Name

Description

TABLE

The table that was specified.

INDEX

The index that was specified.

UPDATED

The date and time when the statistics were last updated.

ROWS

The number of rows in the table.

ROWS_SAMPLED

The number of rows that were used to calculate the statistics information.

STEPS

The number of distribution steps.

DENSITY

The selectivity of the first index column prefix.

AVERAGE_KEY_LENGTH

The average length of all index columns.

RECOMPUTE

A Boolean value. True indicates that this statistic will be automatically updated the next time it is used, if it is determined to be stale.

STALE

A Boolean value. True indicates that the query optimizer has determined that this statistic must be updated. If RECOMPUTE is true, this statistic will be automatically recomputed the next time that the query processor uses this statistic.


The results returned indicate the selectivity of an index. A lower density indicates greater selectivity. The results provide the basis for determining whether an index is useful to the query optimizer.

The following example displays statistics information for all indexes on the Address table.

sp_show_statistics 'Employees'
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.