[Baidu sharing] MySQL5.1 partitioning Technology (2) solution

Source: Internet
Author: User
[Baidu sharing] MySQL5.1 partitioning Technology (2) 2. mySQL partition introduction & nbsp; MySQL partition technology is different from the previous table sharding technology. it is a bit similar to horizontal table sharding, but it is a horizontal table sharding at the logic layer, it is still a table for applications. & Nbsp; 2.1 M [Baidu sharing] MySQL 5.1 partition Technology (2)
2. MySQL partition introduction
The partition technology of MySQL is different from the previous table sharding technology. it is a bit similar to the horizontal table sharding technology, but it is a horizontal table sharding at the logic layer. it is still a table for applications.
2.1 MySQL partition type
MySQL5.1 has 5 partition types:
RANGE partition: multiple rows are allocated to the partition based on the column values in a given continuous interval;
LIST partition: Similar to partitioning by RANGE. The difference is that LIST partitions are selected based on column values matching a value in a discrete value set;
HASH partition: Select a partition based on the return value of a user-defined expression. this expression uses the column values of the rows to be inserted into the table for calculation. This function can contain any expressions that are valid in MySQL and generate non-negative integer values.
KEY partitioning: Similar to HASH partitioning, the difference is that KEY partitioning only supports computing one or more columns, and the MySQL server provides its own HASH function.
2.2 RANGE partition
For RANGE partitions, for example:
Example 1. assume that you have created the following table, which stores records of employees of 20 audio stores. the numbers of these 20 audio stores ranges from 1 to 20. If you want to divide it into four small partitions, you can use the RANGE partition. the database table created is as follows:

In this example, if its key is an integer data type, can it be used as a key for other fields? The answer is No. example 2 illustrates this situation.
Example 2. assume that you have created the following table, which stores records of employees of 20 audio stores. the numbers of these 20 audio stores ranges from 1 to 20. If you want to store employees who have resigned in different periods separately, you can use the date field separated (that is, the departure time) as a key. the created SQL statement is as follows:

In this way, you can call the mysql date function YEAR () for a date field to convert it into an integer type, which can be used as the key of the RANGE partition. At this time, you can see that the physical files after partitioning are relatively independent:

We can see that each partition has its own data file and index file. This is why you only access the data block it needs to access for a query, without accessing a physical block is not a result at all, which can greatly improve the system efficiency.

------ Solution --------------------
JF... Sofa
------ Solution --------------------
I don't know much about this, right?
------ Solution --------------------
I did not understand
------ Solution --------------------
Did not understand!
------ Solution --------------------
It's so simple.
------ Solution --------------------
Dizzy ~

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.