All Products
Search
Document Center

PolarDB:How partitioning works

Last Updated:Mar 28, 2026

PolarDB for Oracle implements partitioned tables through a two-phase pipeline: a syntax parsing module that converts CREATE TABLE statements into an internal node tree, and an execution module that transforms that tree into the actual table structure. This topic explains each phase and describes the available partition management commands.

How partitioned tables are created

Creating a partitioned table involves two modules: syntax parsing and execution.

Syntax parsing module

A partitioned table is created with a CREATE TABLE statement that includes partitioning-specific keywords. The parser uses the following keywords to build its internal representation:

KeywordPurpose
PARTITION BYSpecifies the partitioning strategy and partition key
SUBPARTITION BYSpecifies the partitioning strategy and partition key for subpartitions
INTERVALSpecifies the interval for range partitioning
SUBPARTITION TEMPLATEDefines templates for subpartitioning
(PARTITION xxx)Specifies a list of subpartitions

After receiving the statement, the system converts it into an internal node tree. The following figure shows this conversion.

image.png

The node tree has three levels:

  1. `CreateStmt` — the top-level node for the entire statement.

  2. `partspec` — the first partitioning level; handles the partition key and partitioning strategy.

  3. `PartitionInfor` — the second partitioning level; manages most of the syntax structures. In the figure, colors distinguish the following categories:

    • Intervals

    • Level-1 partitions

    • Level-2 partitions (subpartitions)

    • Partitioning templates

    • List of second-level nodes

Execution module

The executor creates the table in three steps.

Step 1: Store the table definition

The executor stores template information in the table definition for use when creating partitions later. This information is kept in the Option structure:

FieldContent
interval_exprIntervals for range partitioning
sub_part_strategy / sub_part_paramsPartition key and strategy for subpartitions
partition_template_listList of subpartition templates for subsequent partition creation
sub_hash_numberNumber of hash partitions to create hash partitions
image.png

Step 2: Generate partition definitions

The executor converts the stored information into a list of partition definitions:

  1. Generates node trees from either the hash number or the template list:

    • For level-1 partitions, partition_node_list is generated from hash_number.

    • For level-2 partitions (subpartitions), partition_node_list is generated from template_list, if partition templates are defined.

  2. Traverses partition_node_list and fills in key information — the partitioning strategy and partition key.

  3. Checks whether sub_hash_number or template_list is empty. If empty, it indicates that the nodes themselves carry level-2 partition properties. These properties are attached to the level-1 partitions so they can be processed when subpartitions are created.

image.png

Step 3: Create the table

The node list is converted into a creation list. Each PartitionRelNode — including its child nodes — is converted into a CreateStmt node, which the system uses to create the table.

image.png

Manage partitioned tables

The following figure gives an overview of the available partition management commands.

image.png

The commands fall into three categories.

Structural changes

These commands modify the structure or layout of a partitioned table.

CommandDescription
ADDAdds a partition to a partitioned table
DROPDeletes a range- or list-partition
SPLITSplits a single range- or list-partition into two based on a specified value
MERGEMerges two range- or list-partitions into one
COLESCEMerges two hash partitions, reducing the parent hash-partitioned table's partition count by one
MODIFYCollection of management operations on partitions and subpartitions

Data operations

These commands operate on the data within partitions.

CommandDescription
TRUNCATEClears all data in a partition
EXCHANGESwaps the contents of two partitions; the operation must pass a bounds validation check
MOVEMoves a partition to a different storage location

Naming

CommandDescription
RENAMERenames a partition