Rechercher dans le manuel MySQL
23.2 Partitioning Types
[+/-]
This section discusses the types of partitioning which are available in MySQL 8.0. These include the types listed here:
RANGE partitioning. This type of partitioning assigns rows to partitions based on column values falling within a given range. See Section 23.2.1, “RANGE Partitioning”. For information about an extension to this type,
RANGE COLUMNS
, see Section 23.2.3.1, “RANGE COLUMNS partitioning”.LIST partitioning. Similar to partitioning by
RANGE
, except that the partition is selected based on columns matching one of a set of discrete values. See Section 23.2.2, “LIST Partitioning”. For information about an extension to this type,LIST COLUMNS
, see Section 23.2.3.2, “LIST COLUMNS partitioning”.HASH partitioning. With this type of partitioning, a partition is selected based on the value returned by a user-defined expression that operates on column values in rows to be inserted into the table. The function may consist of any expression valid in MySQL that yields a nonnegative integer value. An extension to this type,
LINEAR HASH
, is also available. See Section 23.2.4, “HASH Partitioning”.KEY partitioning. This type of partitioning is similar to partitioning by
HASH
, except that only one or more columns to be evaluated are supplied, and the MySQL server provides its own hashing function. These columns can contain other than integer values, since the hashing function supplied by MySQL guarantees an integer result regardless of the column data type. An extension to this type,LINEAR KEY
, is also available. See Section 23.2.5, “KEY Partitioning”.
A very common use of database partitioning is to segregate data by
date. Some database systems support explicit date partitioning,
which MySQL does not implement in 8.0. However, it is
not difficult in MySQL to create partitioning schemes based on
DATE
,
TIME
, or
DATETIME
columns, or based on
expressions making use of such columns.
When partitioning by KEY
or LINEAR
KEY
, you can use a DATE
,
TIME
, or
DATETIME
column as the partitioning
column without performing any modification of the column value.
For example, this table creation statement is perfectly valid in
MySQL:
- )
- PARTITIONS 6;
In MySQL 8.0, it is also possible to use a
DATE
or
DATETIME
column as the partitioning
column using RANGE COLUMNS
and LIST
COLUMNS
partitioning.
Other partitioning types require a partitioning expression that
yields an integer value or NULL
. If you wish to
use date-based partitioning by RANGE
,
LIST
, HASH
, or
LINEAR HASH
, you can simply employ a function
that operates on a DATE
,
TIME
, or
DATETIME
column and returns such a
value, as shown here:
- )
- );
Additional examples of partitioning using dates may be found in the following sections of this chapter:
For more complex examples of date-based partitioning, see the following sections:
MySQL partitioning is optimized for use with the
TO_DAYS()
,
YEAR()
, and
TO_SECONDS()
functions. However,
you can use other date and time functions that return an integer
or NULL
, such as
WEEKDAY()
,
DAYOFYEAR()
, or
MONTH()
. See
Section 12.7, “Date and Time Functions”, for more information
about such functions.
It is important to remember—regardless of the type of
partitioning that you use—that partitions are always
numbered automatically and in sequence when created, starting with
0
. When a new row is inserted into a
partitioned table, it is these partition numbers that are used in
identifying the correct partition. For example, if your table uses
4 partitions, these partitions are numbered 0
,
1
, 2
, and
3
. For the RANGE
and
LIST
partitioning types, it is necessary to
ensure that there is a partition defined for each partition
number. For HASH
partitioning, the
user-supplied expression must evaluate to an integer value greater
than 0
. For KEY
partitioning, this issue is taken care of automatically by the
hashing function which the MySQL server employs internally.
Names of partitions generally follow the rules governing other
MySQL identifiers, such as those for tables and databases.
However, you should note that partition names are not
case-sensitive. For example, the following
CREATE TABLE
statement fails as
shown:
- -> );
Failure occurs because MySQL sees no difference between the
partition names mypart
and
MyPart
.
When you specify the number of partitions for the table, this must
be expressed as a positive, nonzero integer literal with no
leading zeros, and may not be an expression such as
0.8E+01
or 6-2
, even if it
evaluates to an integer value. Decimal fractions are not
permitted.
In the sections that follow, we do not necessarily provide all possible forms for the syntax that can be used for creating each partition type; for this information, see Section 13.1.20, “CREATE TABLE Syntax”.
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-partitioning-types.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.