Keine Cache-Version


Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code DEF204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.

Rechercher dans le manuel MySQL

23.2.6 Subpartitioning

Subpartitioning—also known as composite partitioning—is the further division of each partition in a partitioned table. Consider the following CREATE TABLE statement:

  1. CREATE TABLE ts (id INT, purchased DATE)
  2.     PARTITION BY RANGE( YEAR(purchased) )
  3.     SUBPARTITION BY HASH( TO_DAYS(purchased) )
  4.     SUBPARTITIONS 2 (
  5.         PARTITION p0 VALUES LESS THAN (1990),
  6.         PARTITION p1 VALUES LESS THAN (2000),
  7.         PARTITION p2 VALUES LESS THAN MAXVALUE
  8.     );

Table ts has 3 RANGE partitions. Each of these partitions—p0, p1, and p2—is further divided into 2 subpartitions. In effect, the entire table is divided into 3 * 2 = 6 partitions. However, due to the action of the PARTITION BY RANGE clause, the first 2 of these store only those records with a value less than 1990 in the purchased column.

It is possible to subpartition tables that are partitioned by RANGE or LIST. Subpartitions may use either HASH or KEY partitioning. This is also known as composite partitioning.

Note

SUBPARTITION BY HASH and SUBPARTITION BY KEY generally follow the same syntax rules as PARTITION BY HASH and PARTITION BY KEY, respectively. An exception to this is that SUBPARTITION BY KEY (unlike PARTITION BY KEY) does not currently support a default column, so the column used for this purpose must be specified, even if the table has an explicit primary key. This is a known issue which we are working to address; see Issues with subpartitions, for more information and an example.

It is also possible to define subpartitions explicitly using SUBPARTITION clauses to specify options for individual subpartitions. For example, a more verbose fashion of creating the same table ts as shown in the previous example would be:

  1. CREATE TABLE ts (id INT, purchased DATE)
  2.     PARTITION BY RANGE( YEAR(purchased) )
  3.     SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
  4.         PARTITION p0 VALUES LESS THAN (1990) (
  5.             SUBPARTITION s0,
  6.             SUBPARTITION s1
  7.         ),
  8.         PARTITION p1 VALUES LESS THAN (2000) (
  9.             SUBPARTITION s2,
  10.             SUBPARTITION s3
  11.         ),
  12.         PARTITION p2 VALUES LESS THAN MAXVALUE (
  13.             SUBPARTITION s4,
  14.             SUBPARTITION s5
  15.         )
  16.     );

Some syntactical items of note are listed here:

  • Each partition must have the same number of subpartitions.

  • If you explicitly define any subpartitions using SUBPARTITION on any partition of a partitioned table, you must define them all. In other words, the following statement will fail:

    1. CREATE TABLE ts (id INT, purchased DATE)
    2.     PARTITION BY RANGE( YEAR(purchased) )
    3.     SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
    4.         PARTITION p0 VALUES LESS THAN (1990) (
    5.             SUBPARTITION s0,
    6.             SUBPARTITION s1
    7.         ),
    8.         PARTITION p1 VALUES LESS THAN (2000),
    9.         PARTITION p2 VALUES LESS THAN MAXVALUE (
    10.             SUBPARTITION s2,
    11.             SUBPARTITION s3
    12.         )
    13.     );

    This statement would still fail even if it used SUBPARTITIONS 2.

  • Each SUBPARTITION clause must include (at a minimum) a name for the subpartition. Otherwise, you may set any desired option for the subpartition or allow it to assume its default setting for that option.

  • Subpartition names must be unique across the entire table. For example, the following CREATE TABLE statement is valid:

    1. CREATE TABLE ts (id INT, purchased DATE)
    2.     PARTITION BY RANGE( YEAR(purchased) )
    3.     SUBPARTITION BY HASH( TO_DAYS(purchased) ) (
    4.         PARTITION p0 VALUES LESS THAN (1990) (
    5.             SUBPARTITION s0,
    6.             SUBPARTITION s1
    7.         ),
    8.         PARTITION p1 VALUES LESS THAN (2000) (
    9.             SUBPARTITION s2,
    10.             SUBPARTITION s3
    11.         ),
    12.         PARTITION p2 VALUES LESS THAN MAXVALUE (
    13.             SUBPARTITION s4,
    14.             SUBPARTITION s5
    15.         )
    16.     );

Suchen Sie im MySQL-Handbuch

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 26/06/2006, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/mysql-rf-partitioning-subpartitions.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:en Manuel MySQL : https://dev.mysql.com/

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut