PolarDB-X supports HASH, KEY, RANGE, LIST, and CO_HASH partitioning types for controlling data distribution across partitions.
Partitioning types
PolarDB-X supports the following partitioning types:
-
HASH partitioning
-
HASH (MySQL-compatible syntax)
-
KEY (MySQL-compatible syntax)
-
-
RANGE partitioning
-
RANGE (MySQL-compatible syntax)
-
RANGE COLUMNS (MySQL-compatible syntax)
-
-
LIST partitioning
-
LIST (MySQL-compatible syntax)
-
LIST COLUMNS (MySQL-compatible syntax)
-
-
Scenario-specific partitioning
CO_HASH (PolarDB-X-specific syntax)
HASH partitioning
HASH partitioning uses a consistent hashing algorithm to compute hash values from partition key columns or partitioning function expressions and routes data accordingly. It includes KEY partitioning (column-based) and HASH partitioning (function-based).
Comparison between KEY partitioning and HASH partitioning
|
Partitioning type |
Supported partition key |
Supports partitioning functions |
Statement syntax |
Limits |
Routing policy (point query) |
|
KEY partitioning (default) |
Single-column partition key |
No |
|
|
|
|
Vector partition key |
No |
|
|
|
|
|
Hash |
Single-column partition key |
No |
|
|
The routing policy of |
|
Yes |
|
|
|||
|
Vector partition key |
No |
|
|
|
RANGE partitioning
RANGE partitioning compares partition key values or partitioning function results against predefined boundaries to route data. It includes RANGE COLUMNS partitioning (column-based) and RANGE partitioning (function-based).
Comparison between RANGE partitioning and RANGE COLUMNS partitioning
|
Partitioning type |
Supported partition key |
Supports partitioning functions |
Statement syntax |
Limits |
Routing policy (point query) |
|
Range Columns |
Single-column partition key and vector partition key |
No |
|
Supports hot partition splitting. If many rows share the same c1 value (for example, 88), you can split by c2. |
|
|
Range |
Single-column partition key |
Yes |
|
|
|
LIST partitioning
LIST partitioning works like RANGE partitioning but matches values against discrete value lists instead of ranges. It includes LIST COLUMNS partitioning (column-based) and LIST partitioning (function-based).
Comparison between LIST partitioning and LIST COLUMNS partitioning
|
Partitioning type |
Supported partition key |
Supports partitioning functions |
Statement syntax |
Limits |
Routing policy (point query) |
|
List Columns |
Single-column partition key and vector partition key |
No |
|
Hot partition splitting is not supported. |
|
|
List |
Single-column partition key |
Yes |
|
Hot partition splitting is not supported. |
COHASH partitioning
PolarDB-X also offers COHASH partitioning for tables that require horizontal partitioning across multiple columns with similar values.
The following table compares COHASH with HASH and KEY partitioning.
Comparison between COHASH partitioning, HASH partitioning, and KEY partitioning
|
Item |
CO_HASH |
KEY |
Hash |
|
Statement syntax |
|
|
|
|
Single-column partition key |
Not supported |
Supported |
Supported |
|
Vector partition key |
Supported |
Supported |
Supported |
|
Partitioning functions on vector partition key columns |
Supported. Example:
|
Not supported |
Not supported |
|
Relationship between partition key columns |
Column values must be similar. You must maintain similarity between partition key columns. Examples:
|
Similar to a composite index prefix. |
Similar to a composite index prefix. |
|
Equivalent query for partition key columns with prefixes, partition pruning, and examples |
Supported. Examples:
|
Supported. Examples:
|
Not supported. Partition pruning requires equivalent conditions on all partition key columns. Examples:
|
|
Equivalent query for partition key columns without prefixes, partition pruning, and examples |
Supported. Equivalent conditions for all partition key columns support partition pruning. Examples:
|
Not supported. Without prefix conditions, all partitions are scanned. Examples:
|
Not supported. Without prefix conditions, all partitions are scanned. Examples:
|
|
Range query |
Not supported. All partitions are scanned. |
Not supported. All partitions are scanned. |
Not supported. All partitions are scanned. |
|
Routing policy (point query) |
|
For more information, see Routing policy in the HASH partitioning section. |
Routing policy is the same as Hash partitioning. |
|
Hot partition splitting |
Not supported. Further hot partition splitting cannot be performed on a hot key value such as |
Supported |
Not supported |
|
Partition management such as partition splitting, merging, and migration |
Supported |
Supported |
Supported |
|
Subpartitioning |
Supported |
Supported |
Supported |