17.05 - Row Partitioning Valid-Time Tables - Teradata Database

Teradata Vantage™ - Temporal Table Support

prodname
Advanced SQL Engine
Teradata Database
vrm_release
17.00
17.05
created_date
June 2020
category
Programming Reference
featnum
B035-1182-170K

The following table describes the recommended partitioning expressions for a valid-time table, where vtcolumn represents the valid-time column.

Valid-Time Column Data Type Recommended Partitioning Expressions
PERIOD(DATE) NOT NULL
PARTITION BY CASE_N(
 END(vtcolumn) >= CURRENT_DATE AT '-12:59',
 NO CASE)

(where AT '-12:59' is a shorthand form of AT INTERVAL -'12:59' HOUR TO MINUTE)

If the valid-time column is a derived period column, the component columns must be defined as NOT NULL, and the derived period column is considered to be defined as NOT NULL.
PERIOD(DATE)
PARTITION BY CASE_N(
 END(vtcolumn) IS NULL OR 
 END(vtcolumn) >= CURRENT_DATE AT '-12:59',
 NO CASE)

(where AT '-12:59' is a shorthand form of AT INTERVAL -'12:59' HOUR TO MINUTE)

PERIOD(TIMESTAMP[(n)] [WITH TIME ZONE]) NOT NULL
PARTITION BY CASE_N(
 END(vtcolumn) >= CURRENT_TIMESTAMP,
 NO CASE)
PERIOD(TIMESTAMP[(n)] [WITH TIME ZONE])
PARTITION BY CASE_N(
 END(vtcolumn) IS NULL OR
 END(vtcolumn) >= CURRENT_TIMESTAMP,
 NO CASE)

By using the recommended physical partitioning for a valid-time table, the physical partitions are as follows:

  • The current partition has rows that are or were valid as of the last resolved CURRENT_DATE or CURRENT_TIMESTAMP value for the partitioning expression and rows that are in the future with respect to that date or timestamp.

    Note that rows with a valid-time column value as NULL are in the current partition (but are not considered current or valid rows).

  • The history partition has rows that were no longer valid as of the last resolved CURRENT_DATE or CURRENT_TIMESTAMP value for the partitioning expression.
Most of the AS OF queries are concerned with times that have already past. Consequently, these queries will not benefit from the recommended partitioning expressions described above. If AS OF queries are expected to be frequent, one way to get the benefit of row partition elimination is to partition on END(< VT_column >) and, within each partition, by BEGIN(< VT_column >) such that there is a 20% distribution within each outer partition.