MySQL 8.0.25 DDL Algorithms: COPY, INPLACE, INSTANT Business Impact Analysis
This article details MySQL 8.0.25's three DDL algorithms—COPY, INPLACE, and INSTANT—explaining their implementation mechanisms, lock behaviors, business impact, default algorithm selection for common operations, VARCHAR length boundary rules, execution time estimates, and key risks like the 64-change INSTANT limit and MDL lock contention.
Reading font

Overview of Three DDL Algorithms in MySQL 8.0.25
MySQL 8.0.25 InnoDB supports three DDL execution algorithms: COPY , INPLACE , and INSTANT . They differ significantly in implementation mechanism, execution efficiency, lock granularity, and business impact. Since MySQL 8.0.12, the default algorithm for any supported DDL operation is INSTANT. MySQL automatically selects the most efficient algorithm supported by the current operation, with priority: INSTANT > INPLACE > COPY. The algorithm can also be explicitly specified via the ALGORITHM= clause.
1. COPY Algorithm
The COPY algorithm is the traditional DDL execution method, performed at the Server layer. Its core flow:
Lock phase: Immediately acquire an exclusive table-level MDL lock; all queries and writes on the table are suspended.
Create a temporary table with the new structure (.frm + tablespace files).
Full data copy: Read rows from the original table and insert into the temporary table.
Record incremental changes: DML operations on the original table are blocked during DDL execution.
Switch table files: Drop the original table and rename the temporary table to the original name.
Rebuild indexes: All indexes are rebuilt along with the data copy.
Release lock: After metadata switch, release the exclusive lock; business reads/writes resume.
The COPY algorithm runs entirely in the Server layer, invoking engine-layer interfaces row by row, generating massive redo/undo logs, and incurring extremely high disk I/O and CPU overhead.
COPY is the most compatible, supporting all structural changes, but its business impact is severe: large tables can cause hours of downtime. Production environments should avoid triggering COPY through proper schema design.
2. INPLACE Algorithm
INPLACE performs changes inside the InnoDB engine layer, avoiding Server-layer row-by-row copy overhead. Depending on whether data/index rebuild is needed, it splits into No-Build (metadata-only) and Build (data/index rebuild) paths. Only the commit phase briefly holds an exclusive lock.
2.1 Prepare Phase
Hold shared MDL lock; concurrent reads allowed.
Create temporary index/data files.
Allocate Row Log buffer to record incremental changes during DDL.
2.2 Execute Phase
Release exclusive lock; allow concurrent DML reads/writes.
Scan original table data, build data pages or index pages per new structure.
Concurrent DML increments are written to the Row Log buffer.
2.3 Commit Phase
Upgrade to exclusive MDL lock; briefly block DML.
Apply Row Log incremental changes to the new structure.
Update data dictionary, switch tablespace files.
Clean up temporary files.
INPLACE does create temporary files internally, but avoids Server-layer row copy. For metadata-only operations (e.g., dropping a secondary index), no data scan is needed.
2.4 No-Build Mode (No Rebuild)
Only modify InnoDB data dictionary metadata; no physical data page scan or modification.
No Row Log buffer overhead; completes in seconds.
Typical scenarios: drop secondary index, modify column default value, VARCHAR expansion within same byte boundary.
2.5 Build Mode (Rebuild)
Full scan of original table data, rebuild data pages or index pages per target structure.
Row Log buffer records concurrent DML increments during execution; applied at commit.
Duration proportional to data volume; only commit phase briefly locks table.
Typical scenarios: add secondary index, adjust primary key, table defragmentation, add column not at end.
3. INSTANT Algorithm
Introduced in MySQL 8.0.12, INSTANT is the most lightweight DDL algorithm. It only modifies metadata in the data dictionary , completely avoiding actual data page operations. Through a metadata versioning mechanism, it achieves read/write compatibility with execution time independent of data volume.
InnoDB maintains a metadata version number per table; DDL increments the version and updates the structure definition without touching disk data.
During INSTANT DDL, only the table structure definition in the data dictionary is updated (column info, default values, comments, etc.).
Data pages remain unmodified; old rows stay in old format.
Subsequent reads parse row data using the latest data dictionary definition. For added columns, old rows are automatically filled with default values (NULL or constant); for dropped columns, the parser skips the deleted column's offset.
New writes use the latest table structure with full row format.
The essence of INSTANT is "metadata first, data lazy update." Physical data page format unification occurs gradually during subsequent DML updates or OPTIMIZE TABLE.
4. Business Impact Comparison
The following timeline compares lock state changes and DML blocking windows for the three algorithms.
4.1 COPY: Exclusive Lock Throughout
Lock held from DDL start until table copy and switch complete.
Blocking window = entire DDL duration, linearly related to data volume; large tables can take hours.
All SELECT/INSERT/UPDATE/DELETE on the table are suspended, causing connection pile-up and potential service avalanche.
Typical triggers: VARCHAR expansion across byte boundary, column type change, charset conversion.
4.2 INPLACE: Two Short Phases, One Long Phase; Only Commit Blocks
Prepare (ms) : Hold upgradable shared MDL lock; allow concurrent DML; only block other DDLs. Work: create temp files, allocate Row Log buffer.
Execute (minutes–hours) : Maintain shared lock; fully allow concurrent DML. Background scan builds new structure while Row Log records increments. Business impact: higher disk I/O, slight performance degradation, no blocking.
Commit (ms–seconds) : Upgrade to exclusive MDL lock; briefly block all DML. Replay Row Log increments, switch tablespace, update data dictionary, clean temp files. This is INPLACE's only business blocking window.
Hidden risk : If a long-running transaction holds a shared MDL lock, the commit phase's exclusive lock request queues, subsequently blocking all DMLs, causing an MDL lock queue avalanche.
4.3 INSTANT: Millisecond Lock, Business Unaware
Lock held only during data dictionary update, typically < 10 ms, then released immediately.
Blocking time extremely short; normal business completely unaffected, no connection pile-up.
No data scan, no I/O pressure, no performance impact.
Note: If a long transaction exists, INSTANT DDL also waits for MDL lock, but waits for transaction end, not for slow DDL execution.
4.4 Summary Comparison Table
5. Common DDL Operations: Default Algorithms and Duration
5.1 Default Algorithms for Common DDL Operations (MySQL 8.0.25)
Based on MySQL 8.0.25, the following lists the default execution algorithm for each common DDL scenario. Adding a single column at the end, modifying column default value, etc., default to INSTANT; adding column with AFTER syntax, dropping column use INPLACE (Rebuild); modifying column type, table charset conversion use COPY.
5.2 VARCHAR Length Boundary Rules
VARCHAR expansion rule core: whether the length prefix byte count changes. 0–255 uses 1 byte; ≥256 uses 2 bytes. Expansion within same interval is Instant; crossing intervals triggers Copy. Shrinking VARCHAR length also requires Copy.
0–255 bytes: 1 byte for length info
≥256 bytes: 2 bytes for length info
Examples (single-byte charset):
VARCHAR(10) → VARCHAR(50) (both 1-byte interval): INPLACE, metadata only
VARCHAR(300) → VARCHAR(500) (both 2-byte interval): INPLACE, metadata only
VARCHAR(50) → VARCHAR(100) (crosses 1→2 byte boundary): COPY, full table rebuildWith utf8mb4 (4 bytes per char), VARCHAR(63) = 252 bytes (1-byte length), VARCHAR(64) = 256 bytes (2-byte length), so 63→64 crosses boundary and triggers COPY.
5.3 Execution Duration Reference (100GB+ InnoDB Table, Tens of Millions of Rows)
INSTANT : Completes within ~10 ms; MDL lock impact within same range.
INPLACE : Duration proportional to data volume. E.g., adding a secondary index requires index rebuild; time spent in index construction. Business impact only during prepare and commit phases (seconds).
COPY : Duration proportional to data volume; blocks business throughout execution.
For COPY-algorithm DDLs, assess maintenance window or use online DDL tools (pt-osc, gh-ost) or phased data migration for large tables.
6. DDL Risk Alerts
INSTANT 64-change limit : Each table supports max 64 INSTANT changes; after limit, run OPTIMIZE TABLE or ALTER TABLE … ENGINE=InnoDB to rebuild and reset counter.
INSTANT silent downgrade : Even with ALGORITHM=INSTANT, tables containing BLOB columns, fulltext indexes, or special storage formats may silently downgrade to INPLACE.
MDL lock chain blocking : DDL waiting for MDL write lock blocks all subsequent requests on that table, potentially filling connection pools.
High-write tables : During INPLACE, concurrent DML writes to row_log; exceeding innodb_online_alter_log_max_size (default 128 MB) causes DDL failure and rollback.
Disk space check : Rebuild and COPY DDLs generate full temporary tablespace; before large table operations, ensure free disk space ≥ 1.2× original table size to avoid out-of-space failures.
Reference Documents:
MySQL 8.0 Official Documentation: 17.12.1 Online DDL Operations
MySQL 8.0 Official Documentation: 17.12.2 Online DDL Performance and Concurrency
MySQL Blog: MySQL 8.0 INSTANT ADD and DROP Column(s)
Database Series: Large Table DDL Change Issues (https://mp.weixin.qq.com/s?__biz=MzI3MzUzMjIxNA==∣=2247486022&idx=1&sn=16ed1a5bda22e27c0cf54b22007f36a9&scene=21#wechat_redirect)
Database Series: InnoDB Online DDL Implementation Mechanism (https://mp.weixin.qq.com/s?__biz=MzI3MzUzMjIxNA==∣=2247484465&idx=1&sn=cf84313a3fe495eece82aeb500da84e0&scene=21#wechat_redirect)
For questions about attribution, corrections or content rights, please contactand we will review it promptly.