The following table describes the recommended partitioning expressions for a bitemporal table, where vtcolumn represents the valid-time column and ttcolumn represents the transaction-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' AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(vtcolumn) < CURRENT_DATE AT '-12:59' AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(ttcolumn) < CURRENT_TIMESTAMP) (where AT '-12:59' is a shorthand form of AT INTERVAL -'12:59' HOUR TO MINUTE) (The END(ttcolumn) < CURRENT_TIMESTAMP expression represents closed rows, and is used instead of NO CASE to achieve better partition elimination.) |
PERIOD(DATE) |
PARTITION BY CASE_N( (END(vtcolumn) IS NULL OR END(vtcolumn) >= CURRENT_DATE AT '-12:59') AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(vtcolumn) < CURRENT_DATE AT '-12:59' AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(ttcolumn) < CURRENT_TIMESTAMP) (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 AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(vtcolumn) < CURRENT_TIMESTAMP AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(ttcolumn) < CURRENT_TIMESTAMP) |
PERIOD(TIMESTAMP[(n)] [WITH TIME ZONE]) |
PARTITION BY CASE_N( (END(vtcolumn) IS NULL OR END(vtcolumn) >= CURRENT_TIMESTAMP) AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(vtcolumn) < CURRENT_TIMESTAMP AND END(ttcolumn) >= CURRENT_TIMESTAMP, END(ttcolumn) < CURRENT_TIMESTAMP) |
By using the recommended row partitioning for a bitemporal table, the partitions are as follows:
- The current partition has rows that are or were valid and open as of the last resolved CURRENT_DATE or CURRENT_TIMESTAMP value for the partitioning expression.
- The valid-time history/transaction-time open partition has rows that are or were no longer valid but were still open as of the last resolved CURRENT_DATE or CURRENT_TIMESTAMP value for the partitioning expression.
- The transaction-time history partition has rows that were closed as of the last resolved CURRENT_DATE or CURRENT_TIMESTAMP value for the partitioning expression.