Rechercher dans le manuel MySQL
23.3.4 Maintenance of Partitions
A number of table and partition maintenance tasks can be carried out on partitioned tables using SQL statements intended for such purposes.
Table maintenance of partitioned tables can be accomplished
using the statements CHECK TABLE
,
OPTIMIZE TABLE
,
ANALYZE TABLE
, and
REPAIR TABLE
, which are supported
for partitioned tables.
You can use a number of extensions to
ALTER
TABLE
for performing operations of this type on one or
more partitions directly, as described in the following list:
Rebuilding partitions. Rebuilds the partition; this has the same effect as dropping all records stored in the partition, then reinserting them. This can be useful for purposes of defragmentation.
Example:
Optimizing partitions. If you have deleted a large number of rows from a partition or if you have made many changes to a partitioned table with variable-length rows (that is, having
VARCHAR
,BLOB
, orTEXT
columns), you can useALTER TABLE ... OPTIMIZE PARTITION
to reclaim any unused space and to defragment the partition data file.Example:
Using
OPTIMIZE PARTITION
on a given partition is equivalent to runningCHECK PARTITION
,ANALYZE PARTITION
, andREPAIR PARTITION
on that partition.Some MySQL storage engines, including
InnoDB
, do not support per-partition optimization; in these cases,ALTER TABLE ... OPTIMIZE PARTITION
analyzes and rebuilds the entire table, and causes an appropriate warning to be issued. (Bug #11751825, Bug #42822) UseALTER TABLE ... REBUILD PARTITION
andALTER TABLE ... ANALYZE PARTITION
instead, to avoid this issue.Analyzing partitions. This reads and stores the key distributions for partitions.
Example:
Repairing partitions. This repairs corrupted partitions.
Example:
Normally,
REPAIR PARTITION
fails when the partition contains duplicate key errors. You can useALTER IGNORE TABLE
with this option, in which case all rows that cannot be moved due to the presence of duplicate keys are removed from the partition (Bug #16900947).Checking partitions. You can check partitions for errors in much the same way that you can use
CHECK TABLE
with nonpartitioned tables.Example:
This command will tell you whether the data or indexes in partition
p1
of tablet1
are corrupted. If this is the case, useALTER TABLE ... REPAIR PARTITION
to repair the partition.Normally,
CHECK PARTITION
fails when the partition contains duplicate key errors. You can useALTER IGNORE TABLE
with this option, in which case the statement returns the contents of each row in the partition where a duplicate key violation is found. Only the values for the columns in the partitioning expression for the table are reported. (Bug #16900947)
Each of the statements in the list just shown also supports the
keyword ALL
in place of the list of partition
names. Using ALL
causes the statement to act
on all partitions in the table.
You can also truncate partitions using
ALTER TABLE ...
TRUNCATE PARTITION
. This statement can be used to
delete all rows from one or more partitions in much the same way
that TRUNCATE TABLE
deletes all
rows from a table.
ALTER TABLE ...
TRUNCATE PARTITION ALL
truncates all partitions in the
table.
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-maintenance.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.