Secondary Indexes
- Secondary Indexes provide another path to access data.
- Teradata allows up to 32 secondary indexes per table.
- Keep in mind; row distribution of records does not occur when secondary indexes are defined.
- The value of secondary indexes is that they reside in a subtable and are stored on all AMPs, which is very different from how the primary indexes (part of base table) are stored.
- Keep in mind that Secondary Indexes (when defined) do take up additional space.
- Secondary Indexes are frequently used in a WHERE clause.
- The Secondary Index can be changed or dropped at any time.
- However, because of the overhead for index maintenance, it is recommended that index values should not be frequently changed.
There are two different types of Secondary Indexes
1.Unique Secondary Index (USI)
2.Non-Unique Secondary Index (NUSI).
Unique Secondary Index:
- Unique Secondary Indexes are extremely efficient.
- A USI is considered a two-AMP operation.
- One AMP is utilized to access the USI subtable row (in the Secondary Index subtable) that references the actual data row, which resides on the second AMP.
Non Unique Secondary Index:
- A Non-Unique Secondary Index is an All-AMP operation and will usually require a spool file.
- Although a NUSI is an All-AMP operation, it is faster than a full table scan.
Secondary indexes can be useful for:
• Satisfying
complex conditions
• Processing
aggregates
• Value
comparisons
• Matching
character combinations
• Joining
tablesA secondary index can be defined as a Unique Secondary Index (USI) or Non-Unique Secondary Index (NUSI).
Syntax:
- CREATE INDEX <index name> (<column list>) ON table name;
No comments:
Post a Comment