15.10 - ResyncStats - Teradata Database

Teradata Database Application Programming Reference

prodname
Teradata Database
vrm_release
15.10
category
Programming Reference
featnum
B035-1090-151K

Removes statistics definitions stored in the TDSTATS database that no longer exist in the dictionary as a result of a SQL DROP statement. In the case of objects marked for preservation after dropping and recreating, the statistics definitions are repaired rather than removed; see related API PreserveAfterRecreate.

REPLACE PROCEDURE TDSTATS.ResyncStats(
 IN DatabaseName VARCHAR(128) CHARACTER SET UNICODE,
 IN TableName    VARCHAR(128) CHARACTER SET UNICODE,
 OUT AutomateId  BIGINT,
 OUT NumRemoved  INTEGER)
       .
       .
       .
       .
;
 

Parameter

Description

DatabaseName

Name of the database. DatabaseName limits the operation to statistics defined in the database you specify.

TableName

Name of the table. TableName limits the operation to the table you specify.

By default, the ResyncStats external stored procedure operates on all statistic definitions defined in the TDSTATS database.

Teradata recommends running ResyncStats when the following occurs:

  • Statistics definitions are automated and dropped as a result of a SQL DROP STATISTICS statement or an ARC restore operation.
  • The RunCollectReport external stored procedure reports errors from collections issued on statistics that no longer exist in the dictionary
  • Synchronizing the TDSTATS Database

    To synchronize the TDSTATS database, you can call one of the following external stored procedures:

  • ResyncStats with DatabaseName and TableName specified as NULL.
  • AutomateStats with DeleteOrphans specified as Y.
  • Note: To copy additional statistics definitions from DBC to the TDSTATS database, use the AutomateStats external stored procedure. For details, see “AutomateStats” on page 488.

     

    Parameter

    Description

    AutomateId

    ID for the history results from this operation.

    NumRemoved

    Number of statistics removed from the TDSTATS database and the number of rows repaired.

    The following example shows how to synchronize the statistics for the Personnel.Employee table.

    CALL TDSTATS.ResyncStats('Personnel','Employee',AutomateId, NumRemovedOrRepaired);
     

    For more information on the ...

    See ...

    SQL DROP STATISTICS statement

    SQL Data Definition Language.

    ARC restore operation

    Teradata Archive/Recovery Utility Reference.

    RunCollectReport external stored procedure

    “RunCollectReport” on page 555.

    DeleteOrphans input parameter or copying statistics

    “AutomateStats” on page 488.