MySQL_ partition

MySQL partition table

  • Several partition the corresponding file and a .frm of several .ibd

    For the engine is a four layer sheet (4 partitions)

    For the server is a table

  • Partition Table influence will affect the gap lock lock range, different table lock does not affect

  • MyiSAM table level lock, a plurality of tables corresponding to partitions, table lock failure

  • Will first partition all partitions visit again

  • The layer server that is a table, a partition is shared lock MDL

  • Partition easy to manage data

Partition type

premise

  • All partitions must be the same storage engine
  • You can not use the primary key, a key other than the partition key as a unique key, or a primary key partition table, the key is not unique, or must include

range partition

Based on the range given a continuous interval (interval require continuous and can not overlap), the data assigned to different partitions

A continuous range of values ​​to a given partition section, a field value satisfies this range will be assigned to a modified partition, the field values ​​are applied to a continuous interval of fields, such as date range, consecutive numbers

list partition

A plurality of partitions disposed a fixed value , if the value of a field in the list of values in this set will be assigned to the partition for the value of field distinction is not high, or if the value is limited, especially as an enumeration such characteristics of the column , list the partition using the logo in some fixed value list

Columns partition

Before mysql5.5 range and only supports integer partitioning list partitions, through additional function operation to obtain additional conversion or an integer, the partition Columns range columns list columns are two kinds of support for integer (tinyint to bigint, decimal not support and float), date (date \ datetime), string (char \ varchar \ binary \ varbinary) three data types

Columns partitioning support one or more fields as the partition key, do not support expressions as the partition key, which is similar range and list partitions should be noted that the comparison of tuples based on the comparison range columns of the partitioning key, which is based on field comparison groups, which are different and range partitioning

hash partitioning

is mainly used to hash dispersed hot read , when data is to ensure that a predetermined number of partitions may be evenly distributed in the, performing a hash partition table, mysql partition key will apply a hash function, the data should be placed in order to determine N partitions in which partition

Mysql supports two hash partitioning:

Conventional linear hash partitioning and hash partitioning (Linear hash partitions), conventional hash algorithm modulo partition uses the algorithm, corresponds to a calculated expression expr he can be saved to which partition, N = MOD (expr, num)

Linear hash partitioning algorithm used is a power of 2 of a linear

Key partition

And hash almost distinguish must use mysql hash function, support for non-integer field partition

Follow key partition is very similar in accordance with hash partitioning, but hash partitioning allows the use of user-defined expressions, and key partition does not allow for self-expression definition, requires the use of hash functions provided by the server mysql, colleagues hash partitioning supports integer value, two key partition supports the other types of column outside of blob or text type as the partition key

And the same hash function, the different partitions may be non int type field, such as type string, date, etc.

Child partitions

Child partitions (subpartiton): the partition table is divided again in each partition, also known as composite partitioning, support for range and list sub-district, sub-partitions can either use the hash partitioning and partition can use key composite partition apply. to save a very large number of data records

Partition advantage

Partition advantage

1, the partition can be divided across multiple disks, a little more storage

2, according to the search condition, that is, where the latter condition, only to find to find the appropriate partitions do not all look the

3, may be performed in parallel processing large data relevant.

4, to spread data across multiple disks queries, to obtain greater query throughput

Published 50 original articles · won praise 32 · views 5335

Guess you like

Origin blog.csdn.net/qq_39787367/article/details/103968190