Sample RUNSTATS control statements
Use the sample control statements as models for developing your own RUNSTATS control statements.
Example 1: Updating catalog statistics for a table space while allowing changes
//STEP1 EXEC DSNUPROC,UID='IUJQU225.RUNSTA',TIME=1440,
// UTPROC='',
// SYSTEM='DSN'
//UTPRINT DD SYSOUT=*
//SYSIN DD *
RUNSTATS TABLESPACE DSN8D12A.DSN8S12E
TABLE(ALL) SAMPLE 25
INDEX(ALL)
Example 2: Updating index statistics
The following control statement specifies that RUNSTATS is to update the catalog statistics for index DSN8810.XEMPL1.
RUNSTATS INDEX (DSN8C10.XEMPL1)
Example 3: Updating index statistics while prohibiting updates
The following control statement specifies that RUNSTATS is to update the catalog statistics for indexes XEMPL1 and XEMPL2. Db2 does not permit other processes to change the table space that is associated with XEMPL1 and XEMPL2 (table space DSN8S12E) while this utility is executing. This restricted access is the default behavior.
RUNSTATS INDEX (DSN8C10.XEMPL1,DSN8C10.XEMPL2)
Example 4: Updating statistics for columns in several tables
The following control statement specifies that RUNSTATS is to update the catalog statistics for the following columns in table space DSN8D12P.DSN8S12C:
- All columns in the TCONA and TOPTVAL tables
- The LINENO and DSPLINE columns in the TDSPTXT table
RUNSTATS TABLESPACE(DSN8D12P.DSN8S12C)
TABLE (TCONA)
TABLE (TOPTVAL) COLUMN(ALL)
TABLE (TDSPTXT) COLUMN(LINENO,DSPLINE)
Example 5: Updating all statistics for a table space
The following control statement specifies that RUNSTATS is to update all catalog statistics (table space, tables, columns, and indexes) for table space DSN8D81P.DSN8S81C.
RUNSTATS TABLESPACE(DSN8D12P.DSN8S12C) TABLE INDEX
Example 6: Updating statistics that are used for access path selection and generating a report
The following control statement specifies that RUNSTATS is to update the catalog with only the statistics that are collected for access path selection. The utility is to report all statistics for the table space and route the report to SYSPRINT.
RUNSTATS TABLESPACE DSN8D12A.DSN8S12E
REPORT YES
UPDATE ACCESSPATH
Example 7: Updating all statistics and generating a report
The following control statement specifies that RUNSTATS is to update the catalog with all statistics (access path and space) for table space DSN8D81A.DSN8S81E. The utility is also to report the collected statistics and route the report to SYSPRINT.
RUNSTATS TABLESPACE DSN8D12A.DSN8S12E
REPORT YES
UPDATE ALL
Example 8: Reporting statistics without updating the catalog
The following control statement specifies that RUNSTATS is to collect statistics for table space DSN8D81A.DSN8S81E and route the report to SYSPRINT. The utility is not to update the catalog with the collected statistics.
RUNSTATS TABLESPACE DSN8D12A.DSN8S12E
REPORT YES
UPDATE NONE
Example 9: Updating statistics for a partition
The following control statement specifies that RUNSTATS is to update the statistics for the first partition of table space DSN8D81A.DSN8S81E and the first partition of the DSN8810.XEMP1 index.
RUNSTATS TABLESPACE DSN8D12A.DSN8S12E PART 1 INDEX(DSN8C10.XEMP1 PART 1)
Example 10: Updating catalog and history tables and reporting all statistics
The following control statement specifies that RUNSTATS is to update the catalog tables and history catalog tables with all statistics for table space DB0E0101.TL0E0101 (including related indexes and columns). The utility is to report the collected statistics and route the statistics to SYSPRINT.
RUNSTATS TABLESPACE DBOE0101.TLOE0101
INDEX
TABLE
REPORT YES
UPDATE ALL
HISTORY ALL
Example 11: Updating statistics on frequently occurring values
Assume that the SYSADM.IXNP1 index is defined on four columns: NP1, NP2, NP3, and NP4. The following control statement specifies that RUNSTATS is to update the statistics for index SYSADM.IXNPI.
The RUNSTATS utility collects cardinality statistics for column NP1, column set NP1 and NP2, and column set NP1, NP2, and NP3, and column set NP1, NP2, NP3, and NP4. The FREQVAL option and its associated parameters indicate that RUNSTATS is also to collect the 5 most frequently occurring values on column NP1 (the first key column of the index), and the 10 most frequently occurring values on the column set NP1 and NP2 (the first two key columns of the index). The utility is to report the collected statistics and route the statistics to SYSPRINT.
RUNSTATS INDEX (SYSADM.IXNPI)
FREQVAL NUMCOLS 1 COUNT 5
FREQVAL NUMCOLS 2 COUNT 10
REPORT YES
Example 12: Updating distribution statistics for a group of specified columns in a table
The following control statement specifies that RUNSTATS is to update statistics for the columns EMPLEVEL, EMPGRADE, and EMPSALARY in table DSN8810.DEPT (in table space DSN8D81A.DSN8S81E). The statement uses the COLGROUP keyword to group these columns. RUNSTATS is to collect the cardinality of this column group and store the cardinality in the SYSCOLDIST catalog table.
RUNSTATS TABLESPACE DSN8D81A.DSN8S81E
TABLE(DSN8810.DEPT)
COLGROUP (EMPLEVEL,EMPGRADE,EMPSALARY)
Example 13: Updating distribution statistics for specific columns and retrieving the most frequently occurring values
The following control statement specifies that RUNSTATS is to update statistics for the columns EMPLEVEL, EMPGRADE, and EMPSALARY in table DSN8810.DEPT. The FREQVAL and COUNT options indicate that RUNSTATS is to collect the 10 most frequently occurring values for each column. The values are to be stored in the SYSCOLDIST and SYSCOLDISTSTATS catalog tables.
RUNSTATS TABLESPACE DSN8D81A.DSN8S81E
TABLE(DSN8810.DEPT)
COLGROUP(EMPLEVEL,EMPGRADE,EMPSALARY) FREQVAL COUNT 10
Example 14: Updating distribution statistics for specific columns in a table and retrieving the least frequently occurring values
The following control statement specifies that RUNSTATS is to update statistics for the columns EMPLEVEL, EMPGRADE, and EMPSALARY in table DSN8810.DEPT. The FREQVAL and COUNT options indicate that RUNSTATS is to collect the 15 least frequently occurring values for each column. The values are to be stored in the SYSCOLDIST and SYSCOLDISTSTATS catalog tables.
RUNSTATS TABLESPACE DSN8D81A.DSN8S81E
TABLE(DSN8810.DEPT)
COLGROUP(EMPLEVEL,EMPGRADE,EMPSALARY) FREQVAL COUNT 15 LEAST
Example 15: Updating distribution statistics for specific columns in a table space and retrieving the most and least frequently occurring values
The following control statement specifies that RUNSTATS is to update statistics for the columns EMPLEVEL, EMPGRADE, and EMPSALARY in table DSN8810.DEPT. The FREQVAL and COUNT options indicate that RUNSTATS is to collect the 10 most frequently occurring values for each column and the 10 least frequently occurring values for each column. The values are to be stored in the SYSCOLDIST and SYSCOLDISTSTATS catalog tables.
RUNSTATS TABLESPACE DSN8D81A.DSN8S81E
TABLE(DSN8810.DEPT)
COLGROUP(EMPLEVEL,EMPGRADE,EMPSALARY) FREQVAL COUNT 10 BOTH
Example 16: Updating statistics for an index and retrieving the most and least frequently occurring values
RUNSTATS INDEX(ADMF001.IXMA0101)
FREQVAL NUMCOLS 1 COUNT 10 BOTH
REPORT YES UPDATE ALL
Example 17: Invalidating statements in the dynamic statement cache for a table space without generating report statistics.
The following control statement specifies that RUNSTATS is to invalidate statements in the dynamic statement cache for table space DSN8D81A.DSN8S81E. However, RUNSTATS is not to collect or report statistics or update the catalog.
RUNSTATS TABLESPACE DSN8D81A.DSN8S81E
REPORT NO
UPDATE NONE
Example 18: RUNSTATS HISTOGRAM job statement.
The following control statement specifies that RUNSTATS is to gather histogram statistics for the specified key columns. Histogram statistics can only be collected on the prefix columns with the same order.
RUNSTATS TABLESPACE RVTDB01.RVTTS01
INDEX ALL
HISTOGRAM NUMCOLS 2 NUMQUANTILES 5
SHRLEVEL(CHANGE)
UPDATE ALL
REPORT YES