The optimizer uses the catalog tables from a database to obtain information about the database, the amount of data in it, and other characteristics, and uses this information to choose the best way to access the data. If current statistics are not available, the optimizer may choose an inefficient access plan based on inaccurate default statistics.
It is highly recommended that you use the runstats command to collect current statistics on tables and indexes, especially if significant update activity has occurred or new indexes have been created since the last time the runstats command was executed. This provides the optimizer with the most accurate information with which to determine the best access plan.
Be sure to use runstats after making your table updates; otherwise, the table may appear to the optimizer to be empty. This problem is evident if cardinality on the Operator Details window equals zero. In this case, complete your table updates, rerun the runstats command and recreate the explain snapshots for affected tables.
Note:
The runstats command (which can be entered from the DB2 CLP prompt) can provide different levels of statistics as shown in the following syntax:
Basic Statistics
Enhanced Statistics
Note: | In each of the above commands, the tablename must be fully qualified with the schema name. |
For more information on the runstats command, see the Administration Guide