Copies the definitions of those statistics identified by a prior Analyzer-related operation as having been used during query optimization but not yet automated to the TDSTATS database.
Syntax
REPLACE PROCEDURE TDSTATS.AutomateUsedStats ( IN DatabaseName VARCHAR(128) CHARACTER SET UNICODE, IN TableName VARCHAR(128) CHARACTER SET UNICODE, IN ObjectListName VARCHAR(128) CHARACTER SET UNICODE, IN AnalysisID INTEGER, IN ExcludeTempTables CHAR(1) CHARACTER SET LATIN, IN MarkApproved CHAR(1) CHARACTER SET LATIN, OUT AutomateId BIGINT, OUT NumCopied INTEGER ) ... ;
Syntax Elements
- DatabaseName
- Name of the database. DatabaseName limits the operation to statistics defined on the database you specify.
- TableName
- Name of the table. TableName limits the operation to statistics defined on the table you specify.
- 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 automated.
- AnalysisID
- Result ID from a prior call to AnalyzeStatsUsage. For more information, see AnalyzeStatsUsage.
- ExcludeTempTables
- Possible values:
- Y or NULL. If you specify Y or NULL, the statistics defined on global temporary tables of the specified databases are excluded from automation. The default value is Y.
- N. If you specify N, the statistics defined on global temporary tables of the specified databases are automated.
- MarkApproved
- Possible values:
- Y or NULL. If you specify Y or NULL, the statistics defined on global temporary tables of the specified databases are excluded from automation. The default value is Y.
- N. If you specify N, the copied statistic is marked unapproved. To approve the statistic, you can call ApproveStat.
- AutomateId
- System supplied ID for the history results from this operation.
- NumCopied
- Number of statistics copied to the TDSTATS database.
Usage Notes
The AutomateUsedStats external stored procedure identifies actively used statistics that must be automated and copies them.
The summarized results from this operation are written to the AutomateHistoryTbl table. To display these results, you can call AutomateReport.
Unless you specify a value of N in the ExcludeTempTables input parameter, any statistics defined on global temporary tables are automatically excluded under the assumption that their management must be highly customized within the user application that populates them.
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.
Example: Using AutomateUsedStats
- Analyze the statistics usage in the Personnel database for queries logged over a seven-day period.
CALL TDSTATS.AnalyzeStatsUsage ('2012-12-01 00:00:00.00','2012-12-31 00:00:00.00', NULL, 'Personnel', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Y', AnalysisId, NumEvents);Result:
*** Procedure has been executed. *** Total elapsed time was 10 seconds. AnalysisId NumEvents ------------- ------------- 2 6
- Identify the results ID (for example, 2) from the call to AnalyzeStatsUsage as having been used during query optimization, if not already done.
CALL TDSTATS.AutomateUsedStats ('Personnel', NULL, NULL, 2, NULL, 'Y', AutomateId, NumCopied);Result:
*** Procedure has been executed. *** Total elapsed time was 10 seconds. AutomateId NumCopied ------------- ------------- 3 2
Related Information
| For more information on ... | See .. |
|---|---|
| displaying the AutomateUsedStats results | AutomateReport. |
| creating or adding object list entries |