Rechercher dans le manuel MySQL
8.5.7 Optimizing InnoDB DDL Operations
Many DDL operations on tables and indexes (
CREATE
,ALTER
, andDROP
statements) can be performed online. See Section 15.12, “InnoDB and Online DDL” for details.Online DDL support for adding secondary indexes means that you can generally speed up the process of creating and loading a table and associated indexes by creating the table without secondary indexes, then adding secondary indexes after the data is loaded.
Use
TRUNCATE TABLE
to empty a table, notDELETE FROM
. Foreign key constraints can make atbl_name
TRUNCATE
statement work like a regularDELETE
statement, in which case a sequence of commands likeDROP TABLE
andCREATE TABLE
might be fastest.Because the primary key is integral to the storage layout of each
InnoDB
table, and changing the definition of the primary key involves reorganizing the whole table, always set up the primary key as part of theCREATE TABLE
statement, and plan ahead so that you do not need toALTER
orDROP
the primary key afterward.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-optimizing-innodb-ddl-operations.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.