Partitioning types
PolarDB-X provides the following partitioning types that you can use to control how data is routed to partitions:
HASH partitioning
HASH (compatible with the HASH partitioning syntax in MySQL)
KEY (compatible with the KEY partitioning syntax in MySQL)
RANGE partitioning
RANGE (compatible with the RANGE partitioning syntax in MySQL)
RANGE COLUMNS (compatible with the RANGE COLUMNS partitioning syntax in MySQL)
LIST partitioning
LIST (compatible with the LIST partitioning syntax in MySQL)
LIST COLUMNS (compatible with the LIST COLUMNS partitioning syntax in MySQL)
Scenario-specific partitioning
CO_HASH (PolarDB-X featured partitioning syntax)
HASH partitioning
This partitioning type uses the built-in consistent hashing algorithm to calculate the hash value of a specified expression that contains a partitioning function or partition key column and routes data to partitions. The HASH partitioning type includes KEY partitioning and HASH partitioning based on whether expressions containing partitioning functions are used or partition key columns are used as partition keys.
Comparison between KEY partitioning and HASH partitioning
Partitioning type | Supported partition key | Support 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
This partitioning type compares and calculates the value of a specified partition key column or the value returned by a specified expression that contains a partitioning function to determine the range of predefined partitions in which data is distributed and routes the data to partitions. The RANGE partitioning type includes RANGE COLUMNS partitioning and RANGE partitioning based on whether expressions containing partitioning functions are used or partition key columns are used as partition keys.
Comparison between RANGE partitioning and RANGE COLUMNS partitioning
Partitioning type | Supported partition key | Support partitioning functions | Statement syntax | Limits | Routing policy (point query) |
Range Columns | Single-column partition key and vector partition key | No |
| Hot partition splitting is supported. If a large number of rows contains the same value, such as 88 in the c1 partition key column, you can split the hot data based on values in the c2 partition key column. |
|
Range | Single-column partition key | Yes |
|
|
|
LIST partitioning
This partitioning type is similar to RANGE partitioning. It compares and calculates the value of a specified partition key column or the value returned by a specified expression that contains a partitioning function to determine the range of predefined partitions in which data is distributed and then routes the data to partitions. The LIST partitioning type includes LIST COLUMNS partitioning and LIST partitioning based on whether multiple partition key columns are used as partition keys and the usage method.
Comparison between LIST partitioning and LIST COLUMNS partitioning
Partitioning type | Supported partition key | Support 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 a new partitioning type, COHASH partitioning, for scenarios where a table needs to be horizontally partitioned based on different partition key columns whose values are similar.
COHASH partitioning is similar to HASH partitioning and KEY partitioning. The following table compares the types.
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 | Values in the columns are similar. You need to maintain the similarity between the values of different partition key columns in a partitioned table. Examples:
| Similar to the prefix of a federated index. | Similar to the prefix of a federated index. |
Equivalent query for partition key columns with prefixes, partition pruning, and examples | Supported. Examples:
| Supported. Examples:
| Not supported. Partition pruning is supported only when equivalent conditions for all partition key columns are included. 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. Equivalent conditions for partitions without prefixes must result in a scan for all partitions. Examples:
| Not supported. Equivalent conditions for partitions without prefixes must result in a scan for all partitions. 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. | For more information, see Routing policy in the Hash partitioning section. |
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 |