The UPDATE STATISTICS statement defines the storage requirements of tables and indexes as well as the value distribution of columns, and stores this information in the database catalog.
Syntax
<update statistics statement> ::=
UPDATE STAT[ISTICS] COLUMN <table name>.<column name> [ESTIMATE [<sample definition>]]
| UPDATE STAT[ISTICS] COLUMN (<column name>,...) FOR <table name> [ESTIMATE [<sample definition>]]
| UPDATE STAT[ISTICS] COLUMN (*) FOR <table name> [ESTIMATE [<sample definition>]]
| UPDATE STAT[ISTICS] <table name> [ESTIMATE [<sample definition>]]
| UPDATE STAT[ISTICS] [<owner>.][<identifier>]* [ESTIMATE [<sample definition>]]
Explanation
When the update statistics statement is executed, information on the table, such as the number of rows, the number of pages used, the sizes of indexes, the value distribution within columns or indexes, etc., is stored in the database catalog. These values are used by the Optimizer to determine the best strategy for executing SQL statements.
You will find information on the Optimizer functions in
The update statistics statement implicitly performs a
COMMIT statement for each base table; i.e. the transaction within which the update statistics statement has been executed is closed.When a
CREATE INDEX statement is executed, the above-mentioned information is stored in the catalog for the index as well as for the base table for which this index is being defined. No information is stored for other indexes defined on this base table.The statistical values stored in the database catalog can be retrieved by selecting the system table OPTIMIZERSTATISTICS. Each row of the table describes statistical values of indexes, columns or the size of a table:
OPTIMIZERSTATISTICS
OWNER |
CHAR ( 32) |
Owner of the table for which statistical information is available |
TABLENAME |
CHAR ( 32) |
Name of a table for which statistical information is available |
INDEXNAME |
CHAR ( 32) |
Name of an index for which statistical information is available |
COLUMNNAME |
CHAR ( 32) |
Name of a column for which statistical information is available |
DISTINCTVALUES |
FIXED (10) |
Number of different values if the current row describes a column or a single-column index; otherwise, the number of rows in a table |
PAGECOUNT |
FIXED (10) |
Number of pages used by an index if the current row describes an index; number of pages in a base table if the current row describes a table; otherwise; NULL |
+AVGLISTLENGTH |
FIXED (10) |
Average number of keys in an index list if the current row describes an index; otherwise, NULL |
<table name>
If a table name is specified, the table must be a non-temporary base table and the user must have a privilege for it.
<column name>
If a column name is specified, this column must exist in specified table.
If * is specified, all columns in the table are assumed.
<identifier>*
Specifying
<identifier>* has the same effect as issuing the update statistics statement for all base tables for which the current user has a privilege, and whose table name begins with the identifier.UPDATE STATISTICS *
The SYSDBA can use UPDATE STATISTICS * to execute the update statistics statement for all base tables, even if the SYSDBA has not been assigned a privilege for these tables.
ESTIMATE
See also:
Statistics system tables