RUNSTATS INDEX syntax and options
RUNSTATS INDEX utility control statements define the operations completed by RUNSTATS utility jobs.
You can create a control statement with the ISPF/PDF edit function. After you create it, save it in a sequential or partitioned data set. When you create the JCL for running the job, use the SYSIN DD statement to specify the name of the data set that contains the utility control statement.
The following syntax and descriptions apply to RUNSTATS INDEX control statements. For the syntax and options of RUNSTATS TABLESPACE control statements, including use of the INDEX keyword, see RUNSTATS TABLESPACE syntax and options.
RUNSTATS INDEX syntax diagram
- 1 REGISTER NO is also accepted, but Db2 issues DSNU124I and uses REGISTER YES for RUNSTATS INDEX.
- 2 You can change the default HISTORY value by modifying the STATISTICS HISTORY subsystem parameter. By default, this value is NONE.
- 3 The KEYCARD option is deprecated. The KEYCARD functionality is now built into the normal execution of the RUNSTATS INDEX utility and cannot be disabled.
- 4 When the COUNT keyword is not specified, the utility automatically determines the count value and collects the most frequently occurring values.
RUNSTATS INDEX option descriptions
- INDEX
- Specifies the indexes on which statistics are to be gathered. Column statistics are gathered on the first column of the index. All of the indexes must be associated with the same table space.
- LIST listdef-name
-
Specifies the name of a
previously defined LISTDEF list name. You can specify one LIST keyword for each RUNSTATS control
statement. When you specify LIST with RUNSTATS INDEX, the list must contain only index spaces. Do
not specify LIST with keywords from the INDEX…(index-name) specification;
except for the correlation-stats-spec.
RUNSTATS groups indexes by their related table space. RUNSTATS INDEX is invoked once per table space. The INDEX keyword is required to validate the contents of the LIST.
- (index-name, …)
- Specifies the indexes on which statistics are to be gathered. You can specify a list of index
names. If you specify more than one index, separate each name with a comma. Enclose the index name
in quotation marks if the name contains a blank.
- PART integer
-
Identifies the index partition on which statistics are to be collected.
integer is the number of the partition.
- (ALL)
- Specifies that statistics are to be gathered on all indexes that are defined on all tables in the specified table space.
- TABLESPACE
- Identifies the
table space and, optionally, the database to which it belongs, for which index statistics are to be
gathered.
- database-name
- The name of the database to which the table space belongs.
The default value is DSNDB04.
- tablespace-name
- The name of the table space for which index statistics are to be gathered.
- KEYCARD
-
The
KEYCARD option is deprecated in the RUNSTATS INDEX control statement and no longer needs to be
specified to collect statistics on the values in the key columns of an index.
Except when processing XML NODEID or XML values indexes, the RUNSTATS utility automatically collects all of the distinct values in all of the 1 to n key column combinations for the specified indexes, where n is the number of columns in the index. For example, suppose that you have an index defined on three columns: A, B, and C. RUNSTATS collects cardinality statistics for column A, column set A and B, and column set A, B, and C. With the deprecation of KEYCARD, this functionality cannot be disabled.
The RUNSTATS utility tolerates the specification of the KEYCARD option. The utility does not issue any messages if the control statement includes or excludes the KEYCARD option when INDEX is specified.
- FREQVAL
- Controls, when
specified with the INDEX option, the collection of frequent-value statistics. If you specify FREQVAL with INDEX,
this keyword must be followed by the NUMCOLS keyword.
RUNSTATS INDEX
ignores FREQVAL MOST/LEAST/BOTH when processing XML NODEID indexes.
- NUMCOLS integer
- Indicates the
number of columns in the index for which RUNSTATS is to collect frequently occurring values.
integer can be a number between 1 and the number of indexed columns. If
you specify a number greater than the number of indexed columns, RUNSTATS uses the number of columns
in the index.
For example, suppose that you have an index defined on three columns: A, B, and C. If you specify NUMCOLS 1, Db2 collects frequently occurring values for column A. If you specify NUMCOLS 2, Db2 collects frequently occurring values for the column set A and B. If you specify NUMCOLS 3, Db2 collects frequently occurring values for the column set A, B, and C.
The default value is 1, which means that RUNSTATS is to collect frequently occurring values on the first key column of the index.
- COUNT integer
- Indicates the
number of frequently occurring values that are to be collected from the specified key columns. For
example, specifying 15 means that RUNSTATS is to collect 15 frequently occurring values from the
specified key columns.
If the COUNT keyword is not specified, the RUNSTATS utility automatically determines the value and collects the most frequently occurring values.
- MOST
- Indicates that the utility is to collect the most frequently occurring values for the specified set of key columns when FREQVAL NUMCOLS COUNT MOST keywords are specified.
- LEAST
- Indicates that the utility is to collect the least frequently occurring values for the specified set of key columns when FREQVAL NUMCOLS COUNT LEAST keywords are specified.
- BOTH
- Indicates that the utility is to collect the most and the least frequently occurring values for the specified set of key columns when FREQVAL NUMCOLS COUNT BOTH keywords are specified.
- HISTOGRAM
-
Indicates, when
specified with the INDEX option (see correlation-stats-spec) for RUNSTATS INDEX, that histogram
statistics are to be gathered for the specified key columns. Histogram statistics can be collected
only on the prefix columns with the same order. Key columns for histogram statistics with a mixed
order are not allowed.
When RUNSTATS collects histogram statistics for partitioned indexes, it aggregates them into SYSCOLDIST. RUNSTATS INDEX ignores the HISTOGRAM keyword when processing XML NODEID indexes.
- NUMQUANTILES integer
- Indicates how
many quantiles that the utility is to collect. The integer value must be
greater than or equal to one. The number of quantiles that you specify should never exceed the total
number of distinct values in the specified key columns. The maximum number of quantiles is 100.
When the NUMQUANTILES keyword is omitted, NUMQUANTILES takes a default value of 100. Based on the number of keys in the index, the number of quantiles is readjusted down to an optimal number.
- SHRLEVEL
-
Indicates whether
other programs that access the table space while RUNSTATS is running must use read-only access or
can change the table space.
- CHANGE
- Allows other programs to change the table space or index. With SHRLEVEL CHANGE, RUNSTATS might collect statistics on uncommitted data.
- REFERENCE
- Allows only read-only access by other programs.
- REGISTER YES
- Specifies that when SHRLEVEL CHANGE behavior is in effect, pages that are read by the RUNSTATS utility in a data sharing environment are registered with the coupling facility. REGISTER YES is always used for RUNSTATS INDEX. If you specify REGISTER NO, Db2 issues message DSNU124I and uses REGISTER YES instead.
- REPORT
-
Specifies
whether RUNSTATS is to generate a set of messages that report the collected statistics.
- NO
- Indicates that RUNSTATS is not to generate the set of messages.
- YES
- Indicates that the set of messages is to be sent as output to SYSPRINT. The messages that RUNSTATS generates depend on the combination of keywords in the utility control statement. However, these messages do not depend on the value of the UPDATE option. REPORT YES always generates a report of space and access path statistics.
- UPDATE
-
Indicates
which collected statistics are to be inserted into the catalog tables.
- ALL
- Indicates that all collected statistics are to be updated in the catalog.
- ACCESSPATH
- Indicates that Db2 is to update the catalog with only those statistics that are used for access path selection.
- SPACE
- Indicates that Db2 is to update the catalog with only space-related statistics.
- NONE
- Indicates that no catalog tables are to be updated with the collected statistics.
Running RUNSTATS always invalidates the dynamic cache. However, when you specify UPDATE NONE REPORT NO, RUNSTATS invalidates statements in the dynamic statement cache without collecting statistics, updating catalogs tables, or generating reports.
- SORTDEVT
-
Specifies the device type that the external sort program uses to
dynamically allocate the sort work data sets that are required.
- device-type
- Specifies any disk device type that is acceptable for the DYNALLOC parameter of the SORT or OPTIONS option of the external sort program.
If all of the following conditions are true, SORTDEVT defaults to SYSALLDA and the temporary data sets are dynamically allocated:
- You omit SORTDEVT.
- A sort is required.
- You did not provide the DD statements that the sort program requires for the temporary data sets
If you specify SORTDEVT and omit SORTNUM, no value is passed to the sort program; the sort program uses its own default.
- SORTNUM
-
Specifies the number of required sort work data sets that the sort program is to allocate.
integer is the number of temporary data sets that can range from 2 to 255.
You need at least two sort work data sets for each sort. The SORTNUM value applies to each sort invocation in the utility. For example, suppose that RUNSTATS is running on three indexes, SORTKEYS is specified, no constraints limit parallelism, and SORTNUM is specified as 8. In thise case, a total of 24 sort work data sets are allocated for a job.
Each sort work data set uses both above the line and below the line virtual storage. Therefore, if you specify too high a value for SORTNUM, the utility might decrease the degree of parallelism due to virtual storage constraints, and possibly decrease the degree down to one, which means that no parallelism is used.
- HISTORY
- Indicates which
statistics are to be recorded in the catalog history tables. The value that you specify for
HISTORY does not depend on the value that you specify for UPDATE.
The default is the value of the STATISTICS HISTORY subsystem parameter on the DSNTIPO installation panel. By default, this parameter value is NONE.
- ALL
- Indicates that all collected statistics are to be updated in the catalog history tables.
- ACCESSPATH
- Indicates that Db2 is to update the catalog history tables with only those statistics that are used for access path selection.
- SPACE
- Indicates that Db2 is to update the catalog history tables with only space-related statistics.
- NONE
- Indicates that no catalog history tables are to be updated with the collected statistics.
- FORCEROLLUP
- Specifies whether aggregation or rollup of statistics is to occur
even if statistics were not gathered on some partitions. This option enables the optimizer to select
the best access path.
- YES
- Indicates that forced aggregation or rollup processing is to be done, even though some partitions might not contain data.
- NO
- Indicates that aggregation or rollup is to be done only if data is available for all partitions.
- INVALIDATECACHE
- Indicates
whether the dynamic statement cache is invalidated.
- YES
- Statements in the dynamic cache are invalidated for the objects that are specified in the job statement.
- NO
- Statements in the dynamic cache are not invalidated for the objects specified in the job statement.
The default value is NO, with the following exceptions:- For RUNSTATS LIST REPORT NO UPDATE NONE, the default value is YES.
- If the RESET ACCESSPATH keyword is specified, the default value is YES, and INVALIDATECACHE NO is not supported.