MySQL Database key partitioning usage

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.