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

Teradata Partitioned Primary Index (PPI) 

What is the Concept behind Partitioning a Table?

  • Each Table in Teradata has a Primary Index unless it is a NoPI table.
  • The Primary Index is the mechanism that allows Teradata to physically distribute the rows of a table across the AMPs.
  • AMPs Sort their rows by the Row-ID, so the system can perform a lightning fast Binary Search since the rows are in Row-ID Order.
  • Partitioning merely tells the AMP to sort its tables’ rows by the Partition first, but then sort the rows by Row-ID within the partition.
  • Partitioning queries will involve all AMPs, but partitioned tables are designed to prevent FULL Table Scans.

Advantages and Disadvantages of Partitioning

Advantages

  • Increase query efficiency by avoiding full table scans
  • PPI’s are defined on a table in order to increase query efficiency by avoiding full table scans without the overhead and maintenance costs of secondary indexes.
  • Deleting large volumes of rows in entire partitions can be extremely fast.
  • For range based queries we can effectively remove SI and use PPI, thus saving overhead of SI subtable.
  • It can access a subset of a large table quickly.
  • Maximum partitions allowed by Teradata – 65,535

Disadvantages

  • Partitioned rows are2 or 8 bytes longer. Table uses more PERM space.
  • A PI access may be degraded if the partitioning column is not part of the PI
  • Joins to non-partitioned tables with the same PI may be degraded.
  • The PI can’t be defined as unique when the partitioning column is not part of the PI.

Creating a PPI Table with Simple Partitioning

  • A PPI table has the AMPs sort (order) the rows on the table by the Partition.
  • This allows for people to avoid Full Table Scans.

A Visual Display of Simple Partitioning

Employee_Table_PPI partitioned by Dept_No, with each AMP sorting its rows into department partitions

An SQL Example that explains Simple Partitioning

Query for Dept_No 300 where the explain plan shows each AMP reading only partition 3

Creating a PPI Table with RANGE_N

  • The expression is evaluated and is mapped into one of a list of specified ranges.
  • Ranges are listed in increasing order and must not overlap with each other.
  • Result is the data row being placed into a partition associated with that range.

Examples:

Example 1 – Creating a PPI Table with RANGE_N Partitioning per Month

CREATE TABLE Order_Table_PPI using PARTITION BY RANGE_N on Order_Date for 2012, each interval 1 month
Callout: sort the rows on each AMP by Order_Date and create a different partition every month
Above Example sort the rows on each AMP by order_date and create a different partition every month

A Visual of One Year of Data with Range_N per Month

Four AMPs, each holding Order_Table_PPI in 12 monthly partitions from January to December

Each AMP sorts their rows by Month (of Order_Date).

An SQL Example explaining Range_N Partitioning per Month

Query for January to March 2012 orders where each of the four AMPs reads only 3 monthly partitions
The above query wants to see orders in the first quarter, so each AMP reads 3 partitions.

Example 2 – Creating a PPI Table with RANGE_N Partitioning per Day

CREATE TABLE Order_Table_PPI with RANGE_N on Order_Date for 2012, each interval 1 day
Above Example sort the rows on each AMP by order_date and create a different partition every Day

A Visual of Range_N Partitioning Per Day

Three AMPs, each storing Order_Table rows in daily partitions numbered from Jan 1 through Feb 2
There would be 365 partitions in total for an entire year of Partitioning per Day. Each AMP holds the orders assigned to them in daily partitions on the day of the order date.

An SQL Example that explains Range_N Partitioning per Day

Query for orders on Jan 1 and Jan 2, 2012 where the explain plan shows each AMP reading 2 partitions

Creating a PPI Table with CASE_N

CREATE TABLE Order_Table_CPPI using PARTITION BY CASE_N on Order_Total, giving six partitions per AMP
If an Order_Total is < 1000, it will go into Partition 1. If an Order_Total is between 1000 and 4999.99, it will go in Partition 2. The NO Case partition is for anything falling through and the UNKNOWN partition is for NULL values in the Total.

A Visual of Case_N Partitioning

CASE_N diagram: three AMPs each split Order_Table_CPPI into six Order_Total partitions, including NO CASE and NULL
There are six partitions for this table. Orders go into partitions based on Order_Total.

An SQL Example that explains CASE_N Partitioning

Query for Order_Total over 20000 makes all AMPs read only partition 5, per the explain plan
All AMPs retrieve, but each only reads partition 5 

Note: NO CASE, NO RANGE, and UNKNOWN options are also available which we can use in RANGE_N and CASE_N Partitioning

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

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….

Read More

Teradata No Primary Index (NOPI) Table

# Contents 1. What is NO PRIMARY INDEX (NOPI) Table? 2. How’s row distributed in AMP for No PRIMARY INDEX (NOPI) table? 3. How it can be…

Read More

Hashing of the Teradata Primary Index

# Contents 1. The Hashing Formula Facts 2. Important Hashing formula Terminology 3. How Hashing Algorithm decides which AMP has the Row? 4. Hashing Theory For Non- Unique…

Read More

What is Teradata Primary Index?

# Contents 1. What is difference between Primary Keys (PK) and Primary Indexes (PI) 2. What is Primary Index? 3. The Teradata Primary Index Choice  (Which Column to…

Read More

How to connect Teradata SQL Assistant to Teradata

In this Tutorial we will learn how to connect Teradata SQL Assistant to Teradata database using Teradata ODBC drive. If you want to install Teradata Database in…

Read More

Installation and Configuration Teradata Tools and Utilities

If you want to learn and practice Teradata database Please find here the guidance how to Installation and Configuration Teradata Tools=and Utilities in your computer. The latest…

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