Share

Teradata Primary and Secondary Index: Understanding the Differences and Importance for Performance Tuning

Learn about the Teradata Primary Index and how it differs from a primary key. Discover the benefits of defining a primary index and how many can be created per table.

Teradata Primary and Secondary Index: Understanding the Differences and Importance for Performance Tuning
tune4

The Teradata primary index differs from a primary key. Its sole purpose is to distribute data evenly among all AMPs. Though the primary index and primary key are frequently equivalent, the primary index is not inherently a primary key.

Is a Teradata Primary Index or Secondary Index required?None of these indices is mandatory. Nevertheless, in most cases, a primary index should be defined.

How many indexes can be defined per index type?A table can have a maximum of one primary index but up to 32 secondary indexes.

How many columns can the indexes consist of?Both the primary and secondary indexes can consist of up to 64 columns.

What about the uniqueness of Teradata indexes?The Teradata primary and secondary indexes can be unique or non-unique. However, the distribution of rows for a non-unique secondary index (NUSI) is different (not distributed according to rowhash).

Can the definition of an index in Teradata be changed?You can drop a secondary index anytime and create it with a different definition.
We cannot change the column set of a primary index. However, you can change it from NUPI to UPI, for example:

ALTER TABLE Customer MODIFY UNIQUE PRIMARY INDEX (>NUPI columns>)

Does the maintenance of the Teradata Primary Index or Secondary Index cause overhead?The primary index deteriorates performance only if the distribution is skewed. No maintenance is needed.

A secondary index deteriorates performance because it is mapped in a sub-table, which must be maintained with every UPDATE and INSERT statement. This means we should only create a secondary index if it is also used!

How is a Teradata Index stored?The primary index does not need its data structure since it simply distributes the rows according to a hashing algorithm.
The secondary index is stored in a sub-table.

What about Row-level Partitioning on Teradata Indexes?Row-level partitioning is only available for the Teradata primary index.

How are the rows on the AMPs sorted?A rowhash of the primary index of an unpartitioned table sorts the rows. If the table is partitioned, it is sorted by rowhash after the rows have been assigned to the correct partitions.
For a non-unique secondary index, the rows can be sorted by the rowhash or value (INTEGER datatype only). The unique secondary index can only be sorted by rowhash.

https://letters.dwhpro.com/content/files/2026/05/performance-tuning-with-the-teradata-ppi.html

Teradata Docs: The Primary Index


Want more practical data engineering analysis like this?

Join DWHPro Letters and get field-tested notes on Teradata, Snowflake, AI, migrations, performance, and enterprise data work. Early subscribers keep launch access before the paid plan launches.

Get the next issue



Planning or surviving an enterprise data platform migration?

I write regularly about the performance, cost, architecture, and project mistakes that show up in real Teradata, Snowflake, Databricks, and enterprise data work.

Subscribe before the paid plan launches and keep launch access.

Written by Roland Wenzlofsky, founder of DWHPro and author of Teradata Query Performance Tuning. DWHPro has helped data warehouse practitioners for 15+ years.

Subscribe to DWHPro Letters

Practical field notes on enterprise data engineering, production AI systems, platform migration, and the senior engineering market.
Written by Roland Wenzlofsky Founder of DWHPro Author of Teradata Query Performance Tuning
Get the next issue
Subscribe