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.3.5 Obtaining Information About Partitions

This section discusses obtaining information about existing partitions, which can be done in a number of ways. Methods of obtaining such information include the following:

From MySQL 8.0.16, when insertions, deletions, or updates are made to partitioned tables, the binary log records information about the partition and (if any) the subpartition in which the row event took place. A new row event is created for a modification that takes place in a different partition or subpartition, even if the table involved is the same. So if a transaction involves three partitions or subpartitions, three row events are generated. For an update event, the partition information is recorded for both the before image and the after image. The partition information is displayed if you specify the -v or --verbose option when viewing the binary log using mysqlbinlog. Partition information is only recorded when row-based logging is in use (binlog_format=ROW).

As discussed elsewhere in this chapter, SHOW CREATE TABLE includes in its output the PARTITION BY clause used to create a partitioned table. For example:

  1. mysql> SHOW CREATE TABLE trb3\G
  2. *************************** 1. row ***************************
  3.        Table: trb3
  4.   `id` int(11) DEFAULT NULL,
  5.   `name` varchar(50) DEFAULT NULL,
  6.   `purchased` date DEFAULT NULL
  7. /*!50100 PARTITION BY RANGE (YEAR(purchased))
  8. (PARTITION p0 VALUES LESS THAN (1990) ENGINE = InnoDB,
  9.  PARTITION p1 VALUES LESS THAN (1995) ENGINE = InnoDB,
  10.  PARTITION p2 VALUES LESS THAN (2000) ENGINE = InnoDB,
  11.  PARTITION p3 VALUES LESS THAN (2005) ENGINE = InnoDB) */
  12. 0 row in set (0.00 sec)

The output from SHOW TABLE STATUS for partitioned tables is the same as that for nonpartitioned tables, except that the Create_options column contains the string partitioned. The Engine column contains the name of the storage engine used by all partitions of the table. (See Section 13.7.6.36, “SHOW TABLE STATUS Syntax”, for more information about this statement.)

You can also obtain information about partitions from INFORMATION_SCHEMA, which contains a PARTITIONS table. See Section 25.17, “The INFORMATION_SCHEMA PARTITIONS Table”.

It is possible to determine which partitions of a partitioned table are involved in a given SELECT query using EXPLAIN. The partitions column in the EXPLAIN output lists the partitions from which records would be matched by the query.

Suppose that a table trb1 is created and populated as follows:

  1. CREATE TABLE trb1 (id INT, name VARCHAR(50), purchased DATE)
  2.     PARTITION BY RANGE(id)
  3.     (
  4.         PARTITION p0 VALUES LESS THAN (3),
  5.         PARTITION p1 VALUES LESS THAN (7),
  6.         PARTITION p2 VALUES LESS THAN (9),
  7.         PARTITION p3 VALUES LESS THAN (11)
  8.     );
  9.  
  10.     (1, 'desk organiser', '2003-10-15'),
  11.     (2, 'CD player', '1993-11-05'),
  12.     (3, 'TV set', '1996-03-10'),
  13.     (4, 'bookcase', '1982-01-10'),
  14.     (5, 'exercise bike', '2004-05-09'),
  15.     (6, 'sofa', '1987-06-05'),
  16.     (7, 'popcorn maker', '2001-11-22'),
  17.     (8, 'aquarium', '1992-08-04'),
  18.     (9, 'study desk', '1984-09-16'),
  19.     (10, 'lava lamp', '1998-12-25');

You can see which partitions are used in a query such as SELECT * FROM trb1;, as shown here:

  1. mysql> EXPLAIN SELECT * FROM trb1\G
  2. *************************** 1. row ***************************
  3.            id: 1
  4.   select_type: SIMPLE
  5.         table: trb1
  6.    partitions: p0,p1,p2,p3
  7.          type: ALL
  8. possible_keys: NULL
  9.           key: NULL
  10.       key_len: NULL
  11.           ref: NULL
  12.          rows: 10
  13.         Extra: Using filesort

In this case, all four partitions are searched. However, when a limiting condition making use of the partitioning key is added to the query, you can see that only those partitions containing matching values are scanned, as shown here:

  1. mysql> EXPLAIN SELECT * FROM trb1 WHERE id < 5\G
  2. *************************** 1. row ***************************
  3.            id: 1
  4.   select_type: SIMPLE
  5.         table: trb1
  6.    partitions: p0,p1
  7.          type: ALL
  8. possible_keys: NULL
  9.           key: NULL
  10.       key_len: NULL
  11.           ref: NULL
  12.          rows: 10
  13.         Extra: Using where

EXPLAIN also provides information about keys used and possible keys:

  1. mysql> ALTER TABLE trb1 ADD PRIMARY KEY (id);
  2. Query OK, 10 rows affected (0.03 sec)
  3. Records: 10  Duplicates: 0  Warnings: 0
  4.  
  5. mysql> EXPLAIN SELECT * FROM trb1 WHERE id < 5\G
  6. *************************** 1. row ***************************
  7.            id: 1
  8.   select_type: SIMPLE
  9.         table: trb1
  10.    partitions: p0,p1
  11.          type: range
  12. possible_keys: PRIMARY
  13.           key: PRIMARY
  14.       key_len: 4
  15.           ref: NULL
  16.          rows: 7
  17.         Extra: Using where

If EXPLAIN is used to examine a query against a nonpartitioned table, no error is produced, but the value of the partitions column is always NULL.

The rows column of EXPLAIN output displays the total number of rows in the table.

See also Section 13.8.2, “EXPLAIN Syntax”.


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-info.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