MySQL partition Overview

Source: Internet
Author: User

Environment:

mysql> select version();+-----------+| version() |+-----------+| 5.5.28    |+-----------+1 row in set (0.00 sec)

Partition is a table design mode.

Partitioning, divide and conquer, focuses on high availability (management), and ancillary value is the improvement of performance

And:
Transparent to the storage engine Layer
Transparent to Application Layer

Supported partition types:

For tables:
Horizontal partitioning → records of different rows in the same table are allocated to different physical files.
For indexes:
▼ Local partition index → A partition stores both data and Indexes

You can run the following command to check whether the partition function is enabled for the current database:

mysql> show variables like '%partition%';+-------------------+-------+| Variable_name     | Value |+-------------------+-------+| have_partitioning | YES   |+-------------------+-------+1 row in set (0.00 sec)

MySQL partition type:
● Range partitioning
● List partitioning
● Hash Partition
● Key Partition

No matter what type of partition is created, if the table has a primary key or a unique index, the partition column must be an integral part of the unique index.

mysql> create table t( col1 int not null,    ->                 col2 int not null,    ->                 col3 int not null,    ->                 col4 int not null,    ->                 unique key (col1,col2)    ->               )    -> partition by hash(col3)    -> partitions 4;ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning functionmysql> create table t( col1 int not null,    ->                 col2 int not null,    ->                 col3 int not null,    ->                 col4 int not null,    ->                 unique key (col1,col2)    ->               )    -> partition by hash(col2)    -> partitions 4;Query OK, 0 rows affected (0.08 sec)

 

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.