Skipping Unneeded Statistics Recollection with the THRESHOLD Option - Teradata Database

Teradata Database Administration

Teradata Database
Release Number
English (United States)
Last Update
Product Category

To skip unneeded statistics recollections, specify the THRESHOLD option of the COLLECT STATISTICS request. With this option, if the amount of data that changed since the last statistics collection is below a specified threshold or the statistics are newer than a specified age, Teradata does not recollect statistics. Either Teradata can determine the appropriate threshold or you can specify a change percentage following the THRESHOLD keyword and/or the number of days. You can issue COLLECT STATISTICS requests at regular intervals without being concerned that you might be wasting I/O and CPU by collecting statistics too soon. Teradata skips the recollections for the statistics whose thresholds are not met and recollects the statistics for those columns that are over the threshold. For example, if the threshold is 10% data change and you request a recollection, Teradata skips recollection if less than 10% of the data changed since the last collection.If you specify the THRESHOLD option the first time you collect statistics, Teradata collects the statistics and remembers the THRESHOLD option. When you recollect statistics, Teradata uses the saved threshold to determine whether statistics recollection is needed. To tell Teradata to ignore the THRESHOLD option (without resetting it) the next time it collects statistics, use the FOR CURRENT option after the percent specification.The following are the two kinds of thresholds that can be used to control the statistics recollections: change-based and time-based.

To use the THESHOLD option, the AutoThresholdPercentForStats field in the DBS Control utility Cost Profile configuration settings must be set to either:

  • 0 (the default: apply the SYSTEM THRESHOLD PERCENT for all statistics that do not have the threshold percent defined)
  • 1 (apply SYSTEM THRESHOLD PERCENT for only new statistics requests that do not have the threshold percent specified)
  • 2 (allows user-specified thresholds but disables the SYSTEM THRESHOLD PERCENT).
  • You can query the LastCollectTimeStamp column of the Data Dictionary table DBC.StatsTbl to see whether data is collected or not.

    The user-specified change threshold percent is not supported for statistics on views and queries.

    For the syntax of the COLLECT STATISTICS statement, see SQL Data Definition Language.