Usage Notes - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
16.10
Published
June 2017
Language
English (United States)
Last Update
2018-04-25
dita:mapPath
psg1480972718197.ditamap
dita:ditavalPath
changebar_rev_16_10_exclude_audience_ie.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

Invocation

Normally invoked using the Teradata Index Wizard utility.

Boundary Options

The following table lists the valid boundary option values and their definitions.

Option Definition
CHANGERATE Every column appearing in an UPDATE SET clause is automatically assigned a change rating ranging from 0 to 9, representing the frequency at which it is updated. For more information about change ratings, see Database Design .

The system assigns columns with a very high update frequency a change rating of 9, while columns that are never updated are assigned a change rating of 0.

Columns with a change rating greater then this user-specified ChangeRate parameter are not considered during index analysis for potential indexes. In other words, the ChangeRate value is a threshold for determining whether to use columns for an index analysis or not.

If the specified ChangeRate parameter is 9, the change rating system is not used to disqualify columns from index analysis.

The default is 5.

The valid range is 0 to 9, where 0 means the column is not updated and 9 means the column is highly volatile with respect to the specified workload.

COLUMNSPERINDEX Maximum number of composite secondary index columns to be considered for index recommendation by the Index Wizard.

The default is 4.

The valid range is 1 to 64.

COLUMNSPERJOININDEX Maximum number of referenced columns in a single-table join index to be considered for index analysis by the Index Wizard.

The default is 8.

The valid range is 1 to 16.

INDEXMAINTMODE Controls how estimated index maintenance costs are used during analysis. The following values are supported.
  • 0

    Maintenance costs are not estimated.

    The feature is disabled.

  • 1

    Maintenance costs are estimated only as supplemental information for the final index recommendations.

    This is the default.

  • 2

    Maintenance costs are used to evaluate and choose between candidate indexes and are also included with the final recommendations.

INDEXESPERTABLE Maximum number of new indexes, including secondary and join indexes, that can be recommended per table.

The default is 16.

The system limit is 32. Each value-ordered secondary index reduces the number of consecutive indexes by 2.

The valid range is 1 to 32.

SEARCHSPACE Maximum size of the search space to be allowed for evaluating index candidates. The higher the number you specify, the more candidate indexes the system can evaluate.

The number specified for SEARCHSPACE corresponds to an internal variable that is used to control the size of the search space evaluated by the index search algorithm.

Keep in mind that the larger the number you specify, the longer the evaluation time. To shorten your evaluation times, change the specification for SearchSpace to a lower number.

The default is 256.

The valid range is 128 to 512.

Rules for Performing INITIATE INDEX ANALYSIS

The following set of rules applies to INITIATE INDEX ANALYSIS:

  • The analysis accepts any of the following DML statements as valid workload components:
    • DELETE
    • INSERT
    • MERGE
    • SELECT
    • UPDATE
  • The specified QCD database must exist in the system. Otherwise, the request aborts and the system returns an error.
  • The specified workload must exist in the specified QCD_name database. Otherwise, the request aborts and the system returns an error.
  • If you specify a table list, then only that list of tables is considered for index analysis.

    If the workload does not contain any tables that match at least one table in the table list, then an error is reported. Otherwise, only the matching list of tables is considered for index analysis.

  • A maximum of 1,024 tables can be analyzed per workload.
  • No error is reported if the same table is specified more than once for index analysis.
  • The index analysis parameters must not be repeated.

    If they are repeated, or if a value is out of range for a parameter, then the request aborts and the system returns an error.

  • If the session is logged off or restarted while INITIATE INDEX ANALYSIS is being performed and no checkpoint is specified, then no index recommendations are saved.

    You must perform the INITIATE INDEX ANALYSIS request again in the restarted session to create the index recommendations.

Sequence of Events for an Index Analysis

The following process indicates the general phases of an index analysis:

  1. The analysis begins when an INITIATE INDEX ANALYSIS request is submitted.
  2. The database query analysis tool analyzes the submitted workload for indexing opportunities.
  3. The index recommendations are written to the IndexRecommendations, IndexColumns, and JoinIndexColumns tables of the specified QCD database.
  4. The recommendations are retrieved for evaluation using a set of SQL SELECT requests defined within a number of macros provided within each QCD.

    For example, the following SELECT request is the core of the Recommendations macro.

         SELECT TableName, DatabaseName, IndexTypeText, SpaceEstimate,             IndexDDL
         FROM IndexRecommendations
         WHERE WorkloadID = :WorkloadID;

    You can find a list of the index recommendation query macros in SQL Request and Transaction Processing .

Retrieving a Completed Index Analysis

After the index analysis completes successfully, you can retrieve the index recommendations from the IndexRecommendations and IndexColumns tables in the appropriate QCD (see SQL Request and Transaction Processing for more information about the QCD).

Using the WITH INDEX TYPE or WITH NO INDEX TYPE Option

You can use this option to either include or exclude various types of secondary and join indexes from consideration for the analysis to be performed on the QCD data by the Teradata Index Wizard.

You can include for consideration, or exclude from consideration, by the analysis any of the following types of indexes.

  • Unique secondary (USI)
  • Nonunique secondary (NUSI)
  • Hash-ordered secondary
  • Value-ordered secondary
  • Single-table simple join
  • Single-table aggregate join

The default, indicated by not specifying this clause in your INITIATE INDEX ANALYSIS request, is to include all valid index types for consideration by the analysis. Note that the list of valid index types for index analysis does not include multitable join indexes or hash indexes.

For example, you might join indexes from consideration by the analysis, which you could consider to be undesirable for workloads that invoke utilities such as Teradata Archive/Recovery or MultiLoad, neither of which can be run against tables that have join indexes defined on them. For more information about restrictions and interactions with tables on which join indexes are defined, see “CREATE JOIN INDEX” in SQL Data Definition Language and Database Design .

In this case, you can substitute FastLoad for MultiLoad to batch load rows into an empty staging table and then use either an INSERT … SELECT request with error logging or a MERGE request with error logging to move the rows into their target table if the scenario permits. For details, see INSERT/INSERT … SELECT, MERGE, and CREATE ERROR TABLE” in SQL Data Definition Language .

Using the CHECKPOINT Option

For long index analyses or cases where the workload has many SQL requests that must be analyzed, you should always specify a checkpoint using the CHECKPOINT option.

The checkpoint trigger value indicates the frequency with which a checkpoint is logged in the AnalysisLog table. A checkpoint is taken after every n request occurrences, where n is the checkpoint trigger value, and the interim index analysis information is logged.

Note that you can specify both the CHECKPOINT and the TIME LIMIT options for an INITIATE INDEX ANALYSIS request.

For information about how to restart a checkpointed index analysis, see RESTART INDEX ANALYSIS.

CHECKPOINT and TIME LIMIT Options

The intent of the CHECKPOINT option and the related RESTART INDEX ANALYSIS statement is to establish safeguards for long running INITIATE INDEX ANALYSIS requests for cases where you want to ensure that you do not have to restart the analysis from the beginning if the request unexpectedly aborts. See RESTART INDEX ANALYSIS.

The TIMELIMIT option permits you to place a time limit on the index analysis. Note that you must be willing to accept the best recommendations found up to that point if you specify this option.

Depending on the size and complexity of the defined workload, the operations undertaken by an INITIATE INDEX ANALYSIS request can be very resource-intensive. The process of repeatedly calling the Optimizer with different sets of candidate indexes incurs heavy CPU usage in the Parsing Engine. You should not use this statement on a production system.

INITIATE PARTITION ANALYSIS and INITIATE INDEX ANALYSIS are related statements in the sense that both first examine a workload and then make recommendations to improve performance. You can submit one or both of these statements in either order for a given workload.

Evaluation of the ChangeRate Variable by INITIATE INDEX ANALYSIS

The following table indicates the method INITIATE INDEX ANALYSIS uses to evaluate column change rate values for index recommendation. Only those columns with a change rate rank  the specified change rate rank are considered for recommendation as an index or composite index component. If no change rate is specified, the default value is 5.

Change Rate Rank Description Percentage of Updates on Column
0 No updates on the column. 0
1 1 update per 1,000,000 selects on the table. .0001
2 1 update per 100,000 selects on the table. .001
3 1 update per 10,000 selects on the table. .01
4 1 update per 1,000 selects on the table. .1
5 1 update per 100 selects on the table. 1
6 5 updates per 100 selects on the table. 5
7 10 updates per 100 selects on the table. 10
8 25 updates per 100 selects on the table. 25
9 More than 25 updates per 100 selects on the table. >25

INITIATE INDEX ANALYSIS Not Supported From Macros

You cannot specify an INITIATE INDEX ANALYSIS request from a macro. If you execute a macro that contains an INITIATE INDEX ANALYSIS request, the system returns an error.