This topic describes what a PolarDB-X partitioned table is, its benefits, and its differences from a MySQL partitioned table.
In an AUTO-mode PolarDB-X database, a logical table with a large amount of data is split into multiple smaller physical tables based on specific partitioning rules. The logical table is called a partitioned table, and each smaller physical table is called a partition of the larger table. PolarDB-X provides a variety of rules for partitioning tables, such as KEY, HASH, RANGE, LIST, and COHASH. These rules can also be flexibly combined to work as level-2 hybrid partitioning rules. This not only allows for efficient data management, but also makes partitioning rules highly compatible with the partitioning syntax of MySQL, thus providing users with a convenient and familiar operation experience.
PolarDB-X also provides a suite of features for convenient O&M and management, such as partition splitting, merging, data migration, and scheduling. Users can flexibly and efficiently manage their data. For example, they can isolate data of a specific partition to an independent storage node or further split a large partition into smaller subpartitions.
Benefits
Supports RANGE, RANGE COLUMN, KEY, LIST, LIST COLUMN, and COHASH partitioning rules and any combination of these partitioning rules for level-2 templated or non-templated partitions. This makes data governance more flexible.
Supports Global Secondary Indexes (GSIs). GSIs facilitate indexing for queries that are made in different dimensions.
Supports partition pruning, which enables optimizers to filter out partitions that do not satisfy specified query conditions. This results in fewer partitions being scanned during queries, thereby reducing engine workload.
Supports PartitionWise Joins. This feature significantly alleviates query loads and enhances query performance. It achieves this by abstracting partitioned tables into partition links and efficiently excluding partitions that do not meet the partitioning criteria.
Supports parallel queries, which boosts query performance by multiple times for large partitioned tables.
Supports flexible partition scheduling to simplify partition-based data isolation.
Comparison with MySQL partitioned tables
Item | PolarDB-X partitioned table | MySQL partitioned table | |
Partition location | Partitions are automatically distributed to different data nodes to smash the resource bottleneck of a single node. | All partitions reside on the primary node and share the resources thereon. | |
Supported partitioning rules |
|
| |
Supported partitioning functions For more information, see Partitioning functions. | You can use functions to express HAHS, RANGE, or LIST rules. The following items list the functions that can be used both in PolarDB-X and MySQL:
The following items list functions that can be used only in PolarDB-X:
| You can use functions to express HAHS, RANGE, or LIST partitioning rules. For information about the functions that you can use to partition a MySQL table, see Partitioning Limitations Relating to Functions. MySQL does not support partitioning functions that use inputs of the character type, such as | |
Hash partitioning rules | HASH |
|
|
KEY |
|
| |
CO_HASH |
| CO_HASH is not supported. | |
Range partitioning rules | RANGE | Supports partitioning functions that use inputs of the character type, such as right/left/substr. For more information, see RANGE partitioning. | Does not support partitioning functions that use inputs of the character type, such as right/left/substr. |
RANGE COLUMNS | Supports a maximum of five partition key columns for partition definition by default. Parameters can be adjusted. For more information, see RANGE COLUMNS partitioning. | Does not limit the number of partition key columns. | |
List partitioning rules | LIST |
|
|
LIST COLUNNS |
|
| |
Secondary partitioning rules | Hybrid rules | Up to 49 hybrid rules can be used based on seven orthometric level-1 partitioning rules and level-2 partitioning rules. |
|
Templated and non-templated | All hybrid rules can be used as templates or non-templates. For more information, see Secondary partitioning. |
| |
Location distribution |
| Partition-level locality is not supported. | |
Partition level changes |
| Partitioned MySQL tables support the following changes to partition definitions:
Most partition-level changes lock tables. | |
Partitioned table redefinition |
|
| |
Partition key column constraints | In PolarDB-X, partitioned tables do not require the primary key and unique key to contain all partition key columns (including level-1 partitions and level-2 partitions). | In MySQL, partitioned tables require the primary key and unique key to contain all partition key columns (including level-1 partitions and level-2 partitions). | |
Global indexes |
| Global indexes are not supported. |