MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Secondary Index in Teradata

#Contents
1.What is Secondary Index in Teradata?
2.When we can Define Secondary Index?
3.Types of Secondary Index
4.Unique Secondary Index (USI)
5.Non Unique Secondary Index (NUSI)
6.Value-Ordered NUSI
7.Advantage and Disadvantage of Secondary Index
8.Primary Index vs. Secondary Index
9.Additional Topic

To Understand More About Secondary Index in Teradata we have to go through below points:

There are 3 general ways to access a table:

  • Primary Index access (one AMP access)
  • Secondary Index access (two or all AMP access)
  • Full Table Scan (all AMP access)

What is Secondary Index in Teradata?

A secondary index provides an alternate pathto the rows of a table.

A secondary index can be used to maintain uniquenesswithin a column or set of columns.

A table can have from 0 to 32 secondary indexes.

Secondary Indexes:

  • Do not affect table distribution.
  • Add overhead, both in terms of disk space and maintenance.
  • May be added or dropped dynamically as needed.
  • Are chosen to improve table performance.

When we can Define Secondary Index?

A Secondary Index may be defined:

  • At table creation (CREATE TABLE)
  • Also can define after table creation Using (CREATE INDEX)
  • may be up to 64 columns

Types of Secondary Index

There are two types of secondary index:

  • Unique Secondary Index (USI)
  • Non Unique Secondary Index (NUSI)

Unique Secondary Index (USI)

  • If the index choice of column(s) is unique, it is called a USI.
  • Unique Secondary Index Accessing a row via a USI is a 2AMP operation.

Syntax to create USI:

CREATE UNIQUE INDEX (EmpNumber) ON Employee;

Non Unique Secondary Index (NUSI)

  • If the index choice of column(s) is non-unique, it is called a NUSI.
  • Non-Unique Secondary Index Accessing row(s) via a NUSI is an all AMP operation

Syntax to create USI:

CREATE INDEX (LastName) ON Employee;

Unique Secondary Index (USI)

A Subtable is created on each AMP anytime a secondary index is created. A secondary index requires a separate physical structure (the subtable ).

What is in a Unique Secondary Index (USI) Subtable?

Three Teradata AMPs, each with base rows and a USI subtable; subtable entry 1003 points to row-ID 3,1 on another AMP

The USI Subtable contains two columns:

1. Emp_No (The USI column)

2. Row-ID of the real Primary Index of the base table

Inside the secondary index subtable is the column Emp_No (USI Column). Then, there is the corresponding Row-ID of the real Primary Index of the table. The USI subtable’s Primary Index is Emp_No, and it is hashed and has a Row-ID like a normal table.

A Unique Secondary Index (USI) Subtable is hashed:

USI subtable rows hashed by Emp_No and spread evenly across AMPs, separate from the base table primary index
  • The USI Subtable spreads the rows evenly among the AMPs. The Primary Index of the Subtable is Emp_No (The USI column).
  • Subtable rows are hashed by their Primary Index (Emp_No) and distributed evenly. They contain the Row-ID of the base row, thus providing a pointer to the AMP and row.

How the Parsing Engine uses the USI Subtable:

Parsing Engine two-AMP plan for SELECT WHERE Emp_No = 1004 using the USI subtable to find row-ID 4,1
  • A USI is a Two-AMP Operation.
  • The first AMP is assigned to read the subtable and the second the base table.
  • Two binary searches are performed in total, and one row is returned.

Non Unique Secondary Index (NUSI)

AMPs before and after CREATE INDEX on First_Name, with a NUSI subtable added on each AMP

A Subtable is created on each AMP.

What is in a Unique Secondary Index (USI) Subtable?


The NUSI Subtable only contains two columns:

  • First_Name (The NUSI column)
  • Row-ID of the real Primary Index of the base table

The NUSI rows get their own Row-ID, but they are not hashed to different AMPs and stay AMP local. That is why NUSI know as AMP locally.

Non- Unique Secondary Index (NUSI) Subtable is AMP Local

AMP-local NUSI subtables pointing only to base table rows on the same AMP

The NUSI Subtable is AMP local because all values in the subtable are of those in the base table (on the same AMP).

How the Parsing Engine uses the NUSI Subtable:

All-AMP Parsing Engine plan for SELECT WHERE First_Name = Kyle, searching each AMP's NUSI subtable
  • First_Name is a Non-Unique Secondary Index!
  • The Parsing Engine will order each AMP to check if they have a ‘Kyle’ in their NUSI Subtable.
  • Each AMP will simultaneously perform a binary search on their NUSI subtable.
  • If an AMP has a ‘Kyle’ the PE will order them to retrieve the base row (AMP Local).
  • If there are 50 AMPs then all 50 AMPs perform a binary search simultaneously and if they find a “Kyle” they perform another binary search on their local base table.

Note:  A NUSI query always searches all AMPs, but the intent is not to do a Full Table Scan. If there are 50 AMPs, then a minimum of 50 binary searches are done.

Drop Secondary Index:

  • Dropping named secondary indexes

DROP INDEX indexname ON tutorial_db.employee;

  • Dropping unnamed secondary indexes

DROP INDEX(co) ON tutorial_db.employee;

Value-Ordered NUSI

It is called a Value Ordered NUSI because subtable is sorted numerically based on actual column value instead being sorted by Secondary Index Value hash.Works best for the range queries.Can be defined only on ‘numeric’ & ‘date’ data types.

Creating a Value-Ordered NUSI

Value-ordered NUSI created on Dept_No, with subtable rows sorted by value instead of hash

Advantage and Disadvantage of Secondary Index

Advantage

  • A table can have up to 32 secondary indexes (including join/hash indexes).
  • Maximum of 64 columns can be added in a single secondary index for a table.
  • Does not affect data distribution for table and can be added or dropped as needed.
  • Improves table access performance by providing alternative path.

Disadvantage

  • Secondary index on multiple columns is less usable.Index would be used only when all columns are used in the WHERE clause.
  • Adds overhead, both in terms of disk space and maintenance.

Primary Index vs. Secondary Index

Table comparing UPI, NUPI, USI and NUSI on uniqueness, binary searches, row distribution and overhead

Additional Topic

Full Table Scans

A full table scan is another way to access data without using any Primary or Secondary Indexes.

Every row of the table must be read.

Full table scans typically occur when either:

  • An index is not used in the query
  • An index is used in a non-equality

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
MotoShare.in is your go-to platform for adventure and exploration. Rent premium bikes for epic journeys or simple scooters for your daily errands—all with the MotoShare.in advantage of affordability and ease.

Related Posts

Top 5 Data Integration Platforms in 2027

Picking a data integration platform used to come down to one question: spreadsheet tool or warehouse pipeline? In 2027, that’s no longer the real dividing line. The…

Read More

Head of Data Engineering: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Head of Data Engineering is the senior leader accountable for building and operating the organization’s data engineering capability: the platforms, pipelines, governance mechanisms, and teams that turn operational data into trusted, secure, and scalable data products. This role owns the data engineering strategy and execution across ingestion, transformation, orchestration, storage, quality, and reliability—enabling analytics, reporting, experimentation, and machine learning.

Read More

Staff Data Platform Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The **Staff Data Platform Engineer** is a senior individual contributor who designs, builds, and operates the shared data platform capabilities that enable reliable analytics, data products, and ML workloads at scale. This role combines deep hands-on engineering with architectural leadership—owning critical platform components (ingestion, storage, compute, orchestration, governance, and observability) and setting technical direction across multiple teams.

Read More

Staff Analytics Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The Staff Analytics Engineer designs, builds, and governs the organization’s trusted analytics data foundation—turning raw operational data into well-modeled, well-documented, and high-quality datasets and metrics that power decision-making, experimentation, and customer/product insights. This role sits at the intersection of data engineering and analytics, with a staff-level mandate to define standards, uplift the analytics engineering practice, and reduce friction from “data creation” to “data consumption.”

Read More

Senior Data Platform Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The **Senior Data Platform Engineer** designs, builds, and operates the core data platform that enables trusted, secure, scalable analytics and data products across the organization. This role focuses on the platform capabilities—ingestion, storage, processing, orchestration, governance, and observability—so that data engineers, analysts, data scientists, and product teams can reliably deliver business outcomes with minimal friction.

Read More

Principal Business Intelligence Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path

The **Principal Business Intelligence Engineer** is a senior individual contributor responsible for designing, building, and governing the enterprise BI ecosystem—spanning semantic models, metrics definitions, dashboards, analytics enablement, and performance/reliability of BI delivery. This role translates complex business questions into trusted, scalable analytics products while setting technical direction and standards for BI engineering across the Data & Analytics organization.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x