All Products
Search
Document Center

ApsaraDB RDS:Use the online DDL feature for an ApsaraDB RDS for MySQL instance

Last Updated:Feb 27, 2026

ApsaraDB RDS instances that run MySQL 5.6 or later support online DDL. This feature lets you run DDL operations, such as index creation, without blocking concurrent DML operations or SELECT queries.

Prerequisites

  • An ApsaraDB RDS for MySQL instance that runs MySQL 5.6 or later

After you upgrade from MySQL 5.5 to MySQL 5.6, the first DDL operation on a table may fail because the table still uses an older format. Run the following statement to convert the table format:
ALTER TABLE <table_name> ENGINE=InnoDB;

Best practices

Important

Perform all DDL operations during off-peak hours to avoid business impact.

  • Set ALGORITHM=INPLACE to reduce disk space and I/O consumption. If the operation does not support in-place processing, MySQL returns an error.

  • Set LOCK=NONE to allow concurrent DML operations. If the operation does not support this lock mode, MySQL returns an error.

By default, ApsaraDB RDS for MySQL sets ALGORITHM to INPLACE and LOCK to NONE. You do not need to specify these clauses explicitly. However, to verify that an operation supports both settings before you run it in production, specify both clauses. MySQL returns an error if either setting is not supported.

Example

ALTER TABLE area ALGORITHM=INPLACE, LOCK=NONE, ADD INDEX idx_fa (father);

If the ALGORITHM=INPLACE clause is not supported, MySQL returns the following error:

ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.

If the LOCK=NONE clause is not supported, MySQL returns the following error:

ERROR 1846 (0A000): LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED.

If your instance runs MySQL 5.5 or earlier and does not support online DDL, use the pt-online-schema-change tool from Percona Toolkit.

For more information about the ALTER TABLE syntax, see ALTER TABLE Syntax.

DDL operations support matrix

The following table lists DDL operations and their online DDL behavior. Column definitions:

  • In-place -- Whether the operation supports the ALGORITHM=INPLACE clause. In-place operations consume less disk space and I/O than table copy operations.

  • Table copy -- Whether the operation requires copying the table, as controlled by the ALGORITHM clause.

  • DML concurrent -- Whether concurrent DML operations are allowed, as controlled by the LOCK clause.

  • Query concurrent -- Whether concurrent SELECT queries are allowed. In most cases, concurrent queries are permitted.

DDL operationIn-placeTable copyDML concurrentQuery concurrentRemarks
Create a common indexYesNoYesYes--
Create a full-text indexYesNoNoYesThe first full-text index on a table requires the table copy method. Subsequent full-text indexes can use the in-place method.
Delete an indexYesNoYesYesModifies metadata only.
Optimize a tableYesYesYesYesCannot use ALGORITHM=INPLACE if the table has a full-text index.
Set a column default valueYesNoYesYesModifies metadata only.
Set an auto-increment column default valueYesNoYesYesModifies metadata only.
Add a foreign key constraintYesNoYesYesRun SET foreign_key_checks=0; to skip table copying.
Delete a foreign key constraintYesNoYesYesYou can enable or disable foreign_key_checks.
Rename a columnYesNoYesYesConcurrent DML is allowed only if the data type remains unchanged.
Add a columnYesYesYesYesNo concurrent DML if the column is auto-increment. ALGORITHM=INPLACE reorganizes table data and increases overhead.
Delete a columnYesYesYesYesALGORITHM=INPLACE reorganizes table data and increases overhead.
Change column orderYesYesYesYesALGORITHM=INPLACE reorganizes table data and increases overhead.
Modify the ROW_FORMAT attributeYesYesYesYesALGORITHM=INPLACE reorganizes table data and increases overhead.
Modify the KEY_BLOCK_SIZE attributeYesYesYesYesALGORITHM=INPLACE reorganizes table data and increases overhead.
Set a column to NULLYesYesYesYesALGORITHM=INPLACE reorganizes table data and increases overhead.
Set a column to NOT NULLYesYesYesYesRequires the sql_mode system variable set to STRICT_ALL_TABLES or STRICT_TRANS_TABLES. The column must not contain NULL values. ALGORITHM=INPLACE reorganizes table data and increases overhead.
Modify a column data typeNoYesNoYes--
Add a primary keyYesYesYesYesALGORITHM=INPLACE reorganizes table data and increases overhead. If the column is set to NOT NULL, ALGORITHM=INPLACE is not supported.
Delete and add a primary keyYesYesYesYesDelete the existing primary key and add a new one in a single ALTER TABLE statement. ALGORITHM=INPLACE reorganizes table data and increases overhead.
Delete a primary keyNoYesNoYes--
Convert a character setNoYesNoYesRequires a table rebuild if the new character set uses a different encoding format.
Specify a character setNoYesNoYesRequires a table rebuild if the new character set uses a different encoding format.
Rebuild a table (FORCE)YesYesYesYesCannot use ALGORITHM=INPLACE if the table has a full-text index.
Rebuild a table (ENGINE=InnoDB)YesYesYesYesCannot use ALGORITHM=INPLACE if the table has a full-text index.
Set the persistent statistics attributeYesNoYesYesModifies metadata only.
Modify a table commentYesNoYesYes--
Even when ALGORITHM=INPLACE is specified, some operations still involve internal table copying. For example, adding a column in-place still reorganizes table data.

For the complete MySQL reference, see Online DDL Operations.

Metadata lock considerations

DDL operations modify table metadata and may need to wait for the metadata lock on the target table. If a long-running transaction holds the lock, the DDL operation blocks. For guidance on resolving metadata lock waits, see Use DMS to release metadata locks.

Troubleshooting: innodb_online_alter_log_max_size exceeded

When you run an online DDL operation on a large table with concurrent DML activity, you may encounter the following error:

ALTER TABLE rd_order_rec ADD INDEX idx_cr_time_detail (cr_time, detail);
ERROR 1799(HY000): Creating index 'idx_cr_time_detail' required more than 'innodb_online_alter_log_max_size' bytes of modification log. Please try again.

Cause

During an online DDL operation, MySQL records concurrent DML changes in a temporary log file. The log file is extended as required by the value of innodb_sort_buffer_size but cannot exceed the value of innodb_online_alter_log_max_size.

When the log file exceeds this limit:

  1. The DDL operation fails.

  2. All uncommitted concurrent DML operations roll back.

Solution

Increase the value of innodb_online_alter_log_max_size in the ApsaraDB RDS console. For instructions, see Modify instance parameters.

A larger log file allows more concurrent DML operations during DDL execution, but it also increases the time the DDL operation takes to lock the table and apply the logged changes at the end. Choose a value that balances concurrency with DDL completion time.

Related information