14. HASH & amp; KEY and mysqlhash of mysql partitions

Source: Internet
Author: User

14. mysql partition HASH & KEY, mysqlhash

1. hash partition ps: I personally think the HASH PARTITION is very good and powerful, and the simple distribution is extremely even to CREATE an instance: CREATE TABLE HASH_EMP (tid int, tname char (255) PARTITION BY HASH (tid) PARTITIONS 8; Perform hash partitioning on the tid of hash_emp, and query the data distribution of the partition in eight zones: select partition_name, partition_expression, partition_description, table_rows from partition where table_schema = schema () and table_name = 'hash _ emp'; + ------------------ + ---------------------- + ------------ ----------- + ------------ + | Partition_name | partition_expression | partition_description | table_rows | + ---------------- + tables + ------------ + | p0 | tid | NULL | 0 | p1 | tid | NULL | 0 | | p2 | tid | NULL | 0 | p3 | tid | NULL | 0 | p4 | tid | NULL | 0 | p5 | tid | NULL | 0 | p6 | tid | NULL | 0 | p7 | tid | NULL | 0 | + -------------- + ------ ---------------- + --------------------- + ------------ + Create an event to continuously write data. Test distribution: create event hash_emp_event on scheduler every 1 second do insert into hash_emp values (NULL, now (); set GLOBAL event_scheduler = 1; // enable the scheduler to view the partition data distribution again: + ---------------- + ---------------------- + ----------------------- + ------------ + | partition_name | partition_expression | partition_description | table_rows | + --- ------------- + ---------------------- + ----------------------- + ------------ + | P0 | tid | NULL | 41 | p1 | tid | NULL | 42 | p2 | tid | NULL | 42 | p3 | tid | NULL | 42 | p4 | tid | NULL | 42 | p5 | tid | NULL | 42 | p6 | tid | NULL | 42 | p7 | tid | NULL | 42 | + ---------------- + ---------------------- + ------------------------- + ------------ + can be seen, hash distribution is extremely even:; 2. key partition PS: the so-called key partition refers to mysql Use the primary KEY or unique TABLE creation for PARTITION management to CREATE an instance: create table KEY_EMP (tid int, tname char (255) partition by key (tid) PARTITIONS 8; PS :: because it is similar to hash, too many tests will not be conducted !!! 3. sub-partition PS: As the name implies, it is to re-create a partition on the partition PS: supports the sub-partition mode range | list, both of them can support creating instances BY hash or list subpartitions: create table ZI_EMP (tid int, tname char (255) partition by range (tid) subpartition by hash (tid) SUBPARTITIONS 2 (PARTITION p0 values less than (1990), PARTITION p1 values less than (2028), PARTITION p2 values less than (MAXVALUE )); divide zi_emp into three range partitions. Each partition is divided into two subpartitions. If so, the following partition structure is available: + partition + ------------ + | partition_name | partition_expression | partition_description | table_rows | + ---------------- + partition + ---------- + | p0 | tid | 1990 | 0 | p0 | tid | 1990 | 0 | p1 | tid | 2028 | 0 | p1 | tid | 2028 | 0 | p2 | tid | MAXVALUE | 0 | p2 | tid | MAXVALUE | 0 | + ---------------- + ---------------------- + ----------------------- + ------------ + that is to say, if tid is less than 1990, the data is allocated to the p0 subpartition by hash.

 


MYSQL hash decryption root: iammysqladmin
For details about how to use hash in mysql, see MySQL help file. chm

MD5 (string)
Calculate the MD5 checksum value of a string as a 32-length hexadecimal number. The return example is used as the hash key.
Mysql> select MD5 ("testing ")
-> 'Ae2b1fca515949e5d54fb22b8ed95575'

RSA Data Security Company MD5 message digest algorithm

Related Article

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.