Partitioned and Nonpartitioned Primary Indexes - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Primary indexes for global temporary, volatile, and standard base tables can be partitioned or nonpartitioned. Nonpartitioned NoPI tables, with the exception of column-partitioned tables, cannot be partitioned because such tables have no primary index to partition. See Column-Partitioned Tables.

An nonpartitioned primary index is the traditional primary index by which rows are assigned to AMPs. Apart from maintaining their storage in row hash order, no additional assignment processing of rows is performed after the rows are hashed to an AMP.

A partitioned primary index (PPI) permits rows to be assigned to user-defined data partitions on the AMPs, enabling enhanced performance for range queries that are predicated on primary index values. For details, see Partitioned and Nonpartitioned Primary Indexes and EXPLAIN Request Modifier and Partitioned Primary Index Access.

You can define partitioning on a single level or on multiple levels. A PPI defined on multiple levels is called a multilevel PPI, or MLPPI.

Depending on the number of combined partitions for a table, its partition numbers consume either 2 bytes or 8 bytes in the row header, as the following table specifies.

Number of Combined Partitions Number of Row Header Bytes Partition Number Consumes
≤   65, 535 2
> 65,535 8

Single-level column partitioning with no ADD option also consumes 2 bytes in the row header.

Partition assignment is based on how the partitioning expression is defined. The partitioning expressions for multilevel partitioning must be defined using only CASE_N or RANGE_N expressions in any combination. The functions CASE_N and RANGE_N are designed specifically to support simple partitioning expressions. But, you can write any valid SQL expression as a partitioning expression for single-level partitioning, with the following exclusions:
  • Comparison of CHARACTER or CHARACTER SET GRAPHIC data involving columns or expressions using the Kanji1 or KanjiSJIS server character sets.
  • User-defined function
  • Aggregate functions
  • Ordered analytical functions
  • Built-in functions
  • The RANDOM function
  • The HASHAMP and HASHBAKAMP functions

    HASHROW and HASHBUCKET are permitted.

  • The system-derived PARTITION and PARTITION#L n columns
  • Set operators
  • Subqueries
  • Columns having a BLOB, CLOB, or Geospatial data type.
You can base a partitioning expression for single-level partitioning on any of the following general forms.
  • Direct partitioning on a numeric column
  • Expressions based on 1 or more columns
  • Expressions based on the CASE_N function
  • Expressions based on the RANGE_N function

See Partitioned and Nonpartitioned Primary Indexes for details on the usage considerations for each of these partitioning strategies.

Partitioning expressions for multilevel partitioning can be based only on the following general forms in any combination.
  • Expressions based on the CASE_N function
  • Expressions based on the RANGE_N function

Use the CASE_N function to define a mapping between conditions to INTEGER numbers.

Use the RANGE_N function to define a mapping of ranges of INTEGER or DATE values to INTEGER numbers.

The partitioning expressions you can define for partitioning a table have restrictions on the data types of their component values, including values returned by functions.

The following table summarizes these restrictions.

Data Type PARTITION BY
RANGE_N CASE_N Expression
ARRAY

VARRAY

N N N
BIGINT Y X I
BLOB N N N
BYTE X X X
BYTEINT Y X I
CHARACTER Y X I
CLOB N N N
DATE Y X I
DECIMAL

NUMERIC

X X I
NUMBER (exact form) X X I
DOUBLE PRECISION

FLOAT

REAL

X X I
NUMBER (approximate form) X  X I
GRAPHIC N   X N
INTEGER Y X Y
INTERVAL YEAR X X I
INTERVAL YEAR TO MONTH X X X
INTERVAL MONTH  X  X I
INTERVAL DAY  X X I
INTERVAL DAY TO HOUR X X X
INTERVAL DAY TO SECOND X X X
INTERVAL SECOND  X X X
LONG VARCHAR Y X I
LONG VARCHAR CHARACTER SET GRAPHIC N N N
PERIOD

The BEGIN and END bound functions are valid in a partitioning expression when defined on a valid PERIOD column and the result can be cast implicitly to a numeric data type.

N X N
SMALLINT Y X I
TIME X X X
TIME WITH TIME ZONE X X X
TIMESTAMP Y X X
TIMESTAMP WITH TIME ZONE Y X X
UDT N N N
VARBYTE X X X
VARCHAR Y X I
VARGRAPHIC N N N
JSON N N N
XML N N N

The following table explains the abbreviations used in the previous table.

Key
Symbol Definition
I Valid for a partitioning expression.

If the type is also the data type of the result, then the type must be one that can be cast to a valid INTEGER value.

N Not valid for a partitioning expression.

If the partitioning expression is defined using a CASE_N function, then this type is not valid for the CASE_N condition.

X Valid for a partitioning expression, but cannot be the data type of the result of the expression.

If the partitioning expression is defined using a CASE_N function, then this type is valid for the CASE_N condition.

Y Valid for a partitioning expression and valid as the data type of the result of the partitioning expression.