Updates statistics about the physical characteristics of a table and the associated indexes. These characteristics include number of records, number of pages, and average record length. The optimizer uses these statistics when determining access paths to the data.
This utility should be called when a table has had many updates, or after reorganizing a table.
Scope
This command can be issued from any node in the db2nodes.cfg file. It can be used to update the catalogs on the catalog node.
The command collects statistics for a table on the node from which it is invoked. If the table does not exist on that node, the first node in the nodegroup is selected.
Authorization
One of the following:
Required Connection
Database
Command Syntax
>>-RUNSTATS ON TABLE--table-name--------------------------------> >--+-+-------------------------------------------------------------------+-+> | +-WITH DISTRIBUTION--+-------------------------------------------+--+ | | +-AND-+----------+---+-INDEXES ALL--------+-+ | | +-DETAILED-+ +-INDEX--index-name--+ | +-+-----------------------------------------------+---------------------+ +--+-AND-++----------+---+-INDEXES ALL--------+-+ +-FOR-++-DETAILED-+ +-INDEX--index-name--+ >--+-------------------------+--------------------------------->< | +-CHANGE----+ | +-SHRLEVEL--+-REFERENCE-+-+ |
Command Parameters
Examples
Collect statistics on table only, without distribution statistics:
db2 runstats on table smith.table1
Collect statistics on table only, with distribution statistics:
db2 runstats on table smith.table1 with distribution
Collect basic statistics on indexes only:
db2 runstats on table smith.table1 for indexes all
Collect statistics on table and all indexes (basic level):
db2 runstats on table smith.table1 and indexes all
Collect statistics on table, with distribution statistics and index statistics:
db2 runstats on table smith.table1 with distribution and indexes all
Collect all possible statistics (distribution and extended index):
db2 runstats on table smith.table1 with distribution and detailed index
Collect distribution statistics on index INDEX1 only:
db2 runstats on table smith.table1 with distribution for index smith.index1
Usage Notes
Use RUNSTATS to update the statistics on tables:
After statistics have been updated, new access paths to the table can be created by rebinding the packages using BIND.
Statistics for tables only should be collected before any indexes are created. This will ensure that statistics gathered during index creation are not overlaid by estimates gathered during the calculation of table statistics.
Statistics are collected based on the table partition that is resident on the node where the command executes. Global table statistics are derived by multiplying the values obtained at a node by the number of nodes on which the table is completely stored. The global statistics are stored in the catalog tables.
The node from which the command is issued does not have to contain a partition for the table:
See Also