Identifies statistics not used by query optimization for a specified period of time according to the system maintained activity counters and optionally reactivates them.
Definition
REPLACE PROCEDURE TDSTATS.CleanupStats (IN OlderThan TIMESTAMP(6) WITH TIME ZONE, IN DatabaseName VARCHAR(128) CHARACTER SET UNICODE, IN TableName VARCHAR(128) CHARACTER SET UNICODE, IN ObjectListName VARCHAR(128) CHARACTER SET UNICODE, IN MarkInactive CHAR(1) CHARACTER SET LATIN, OUT AnalysisId BIG, OUT NumEvents INTEGER) . . . ;
Input Parameters
Parameter | Description |
---|---|
OlderThan | Time. OlderThan identifies statistics that have not been used since the time you specify as inactive. |
DatabaseName | Name of the database. DatabaseName limits the cleanup operation to statistics within the database you specify. This input parameter may contain wildcard characters (%, _). For more information about wildcard characters, see “Usage Notes.” |
TableName | Name of the table within the specified DatabaseName. TableName limits the cleanup operation to the statistics defined on the table you specify within DatabaseName. This input parameter may contain wildcard characters (%, _). For more information about wildcard characters, see “Usage Notes.” |
ObjectListName | Name of the object list. ObjectListName allows you to specify a previously defined list of objects (that is, one or more database names or fully qualified table names where each name entry may optionally contain wildcard characters) whose statistics should be cleaned. For more information about this input parameter, see “Usage Notes” or CreateObjectList. |
MarkInactive | Possible values:
|
Usage Notes
The CleanupStats results are written to the AnalyzerHistoryTbl table. To display the results, you can call CleanupStatsReport.
Enabling Object Use Counts for Statistics
Before calling CleanupStats, you must enable object use counts for statistics for queries accessing the specified DatabaseName and TableName.
Identifying Statistics
To identify only the statistics not used for query optimization for a ... | You must specify a value for ... |
---|---|
particular database | DatabaseName |
particular table | both DatabaseName and TableName |
a list of objects that cannot be specified by DatabaseName or TableName |
ObjectListName that was previously created by the CreateObjectList and AddObjectListEntry external stored procedures. ObjectListName usage is mutually exclusive with DatabaseName and TableName . When you specify a value other than NULL for ObjectListName , DatabaseName and TableName must be NULL. |
Wildcard Characters
Character | Description |
---|---|
% (PERCENT SIGN) | Represents any string of zero or more arbitrary characters. Any string of characters is acceptable as a replacement for the percent. |
_ (LOW LINE) | Represents exactly one arbitrary character. Any single character is acceptable in the position in which the underscore character appears. |
For more information on how to use these wildcard characters, see the SQL LIKE clause in Teradata Vantage™ - SQL Functions, Expressions, and Predicates, B035-1145.
Output Parameters
Parameter | Description |
---|---|
AnalysisId | Results ID for all events generated by this operation. |
NumEvents | Number of statistics inactivated or reactivated as a result of the cleaning. |
Example: Using CleanupStats
The following example shows how to identify the statistics not used on the Personnel.Employee database in the last year.
CALL TDSTATS.CleanupStats(,(CAST(CURRENT_DATE - INTERVAL '1' YEAR AS TIMESTAMP(6)), 'Personnel', 'Employee', NULL, 'N', AnalysisId, NumEvents); *** Procedure has been executed. *** Total elapsed time was 1 second. AnalysisId NumEvents ---------- --------- 6 3
Related Topics
For more information on ... | See ... |
---|---|
displaying the CleanupStats results report | CleanupStatsReport. |
the SQL BEGIN QUERY LOGGING statement and the USECOUNT logging option | Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144. |