Creating statistics profiles

You can create and use statistics profiles to collect statistics for particular tables with consistent options, without the need to explicitly specify the options each time. Db2 also uses the statistics profiles when you implement autonomic statistics maintenance.

About this task

Db2 uses statistics profiles when you enable autonomic statistics maintenance. When you first enable autonomic statistics maintenance, the ADMIN_UTL_MONITOR stored procedure sets a profile for each monitored table based on the existing statistics. However, if a profile exists for a table, Db2 uses the existing profile.

Procedure

To set a statistics profile, complete one of the following actions:

  • Start of change Set the value of the STATFDBK_PROFILE subsystem parameter to YES.
    When you specify this option, Db2 automatically creates and modifies profiles based on statistics recommendations when it writes the recommendations to the SYSIBM.SYSSTATFEEDBACK catalog table. For more information about this approach, see Applying statistics recommendations to statistics profiles automatically.
    End of change
  • Issue the following utility control statement to explicitly specify collection options for the profile:
    RUNSTATS TABLESPACE ts-name TABLE table-name runstats-options SET PROFILE
    Db2 records the values specified by runstats-options in the PROFILE_TEXT column of the SYSIBM.SYSTABLES_PROFILES catalog table. Db2 uses the default values for any options that are not specified.
  • Issue the following utility control statement to automatically specify options in the profile based on the existing statistics for the specified table:
    RUNSTATS TABLESPACE ts-name TABLE table-name SET PROFILE FROM EXISTING STATS
    Start of changeThe generated profile is based on the statistics that exist in the catalog tables. However, the keywords used in the generated profile do not necessarily match the keywords that were used to collect the statistics previously.End of change

Results

When you specify the SET PROFILE option, the RUNSTATS utility collects no statistics and a new statistics profile is created. If a profile exists for the specified table, that profile is replaced with the new one, and the existing profile is lost. Only one profile can exist for a particular table.

Start of changeFL 507 When you later collect statistics with the RUNSTATS TABLESPACE, REORG TABLESPACE, or LOAD utilities with USE PROFILE, the utility also removes any statistics that are not included in the profile.End of change