MySQL Database key partitioning usage
Partitioning according to key is similar to following a hash partition, except for a user-defined expression used by the hash partition, and the hash function of the key partition is provided by the MySQL server. The MySQL cluster (Cluster) uses function MD5 () to implement the key partition, and for tables using other storage engines, the server uses its own internal hash function, which is based on the same algorithm as password ().
"CREATE TABLE ... The syntax rules for PARTITION by KEY are similar to the rules for creating a table that passes through a hash partition. The only difference is that the keyword used is key instead of hash, and a key partition takes only one list of one or more column names.
It is also possible to divide a table by a linear key. The following is a simple example:
CREATE TABLE tk (
Col1 INT not NULL,
Col2 CHAR (5),
Col3 DATE
)
PARTITION by LINEAR KEY (col1)
Partitions 3;
Using keyword linear in a key partition and having the same effect in a hash partition, the partition number is obtained by a power (powers-of-two) algorithm of 2, rather than through a modulus algorithm.