Rechercher dans le manuel MySQL
15.12.6 Online DDL Limitations
The following limitations apply to online DDL operations:
The table is copied when creating an index on a
TEMPORARY TABLE
.The
ALTER TABLE
clauseLOCK=NONE
is not permitted if there areON...CASCADE
orON...SET NULL
constraints on the table.Before an in-place online DDL operation can finish, it must wait for transactions that hold metadata locks on the table to commit or roll back. An online DDL operation may briefly require an exclusive metadata lock on the table during its execution phase, and always requires one in the final phase of the operation when updating the table definition. Consequently, transactions holding metadata locks on the table can cause an online DDL operation to block. The transactions that hold metadata locks on the table may have been started before or during the online DDL operation. A long running or inactive transaction that holds a metadata lock on the table can cause an online DDL operation to timeout.
When running an in-place online DDL operation, the thread that runs the
ALTER TABLE
statement applies an online log of DML operations that were run concurrently on the same table from other connection threads. When the DML operations are applied, it is possible to encounter a duplicate key entry error (ERROR 1062 (23000): Duplicate entry), even if the duplicate entry is only temporary and would be reverted by a later entry in the online log. This is similar to the idea of a foreign key constraint check inInnoDB
in which constraints must hold during a transaction.OPTIMIZE TABLE
for anInnoDB
table is mapped to anALTER TABLE
operation to rebuild the table and update index statistics and free unused space in the clustered index. Secondary indexes are not created as efficiently because keys are inserted in the order they appeared in the primary key.OPTIMIZE TABLE
is supported with the addition of online DDL support for rebuilding regular and partitionedInnoDB
tables.Tables created before MySQL 5.6 that include temporal columns (
DATE
,DATETIME
orTIMESTAMP
) and have not been rebuilt usingALGORITHM=COPY
do not supportALGORITHM=INPLACE
. In this case, anALTER TABLE ... ALGORITHM=INPLACE
operation returns the following error:The following limitations are generally applicable to online DDL operations on large tables that involve rebuilding the table:
There is no mechanism to pause an online DDL operation or to throttle I/O or CPU usage for an online DDL operation.
Rollback of an online DDL operation can be expensive should the operation fail.
Long running online DDL operations can cause replication lag. An online DDL operation must finish running on the master before it is run on the slave. Also, DML that was processed concurrently on the master is only processed on the slave after the DDL operation on the slave is completed.
For additional information related to running online DDL operations on large tables, see Section 15.12.2, “Online DDL Performance and Concurrency”.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-innodb-online-ddl-limitations.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.