## 15.12 InnoDB and Online DDL

[15.12.1 Online DDL Operations](innodb-online-ddl-operations.html)
[15.12.2 Online DDL Performance and Concurrency](innodb-online-ddl-performance.html)
[15.12.3 Online DDL Space Requirements](innodb-online-ddl-space-requirements.html)
[15.12.4 Online DDL Memory Management](online-ddl-memory-management.html)
[15.12.5 Configuring Parallel Threads for Online DDL Operations](online-ddl-parallel-thread-configuration.html)
[15.12.6 Simplifying DDL Statements with Online DDL](innodb-online-ddl-single-multi.html)
[15.12.7 Online DDL Failure Conditions](innodb-online-ddl-failure-conditions.html)
[15.12.8 Online DDL Limitations](innodb-online-ddl-limitations.html)

[]()[]()

 The online DDL feature provides support for instant and in-place table alterations and concurrent DML. Benefits of this feature include:

* Improved responsiveness and availability in busy production environments, where making a table unavailable for minutes or hours is not practical.

* For in-place operations, the ability to adjust the balance between performance and concurrency during DDL operations using the `LOCK` clause. See [The LOCK clause](innodb-online-ddl-performance.html#innodb-online-ddl-locking-options).

* Less disk space usage and I/O overhead than the table-copy method.

Note

`ALGORITHM=INSTANT` support is available for `ADD COLUMN` and other operations in MySQL 8.0.12.

 Typically, you do not need to do anything special to enable online DDL. By default, MySQL performs the operation instantly or in place, as permitted, with as little locking as possible.

 You can control aspects of a DDL operation using the `ALGORITHM` and `LOCK` clauses of the [`ALTER TABLE`](alter-table.html) statement. These clauses are placed at the end of the statement, separated from the table and column specifications by commas. For example:

```
ALTER TABLE tbl_name ADD PRIMARY KEY (column), ALGORITHM=INPLACE, LOCK=NONE;
```

 The `LOCK` clause may be used for operations that are performed in place and is useful for fine-tuning the degree of concurrent access to the table during operations. Only `LOCK=DEFAULT` is supported for operations that are performed instantly. The `ALGORITHM` clause is primarily intended for performance comparisons and as a fallback to the older table-copying behavior in case you encounter any issues. For example:

* To avoid accidentally making the table unavailable for reads, writes, or both, during an in-place [`ALTER TABLE`](alter-table.html) operation, specify a clause on the [`ALTER TABLE`](alter-table.html) statement such as `LOCK=NONE` (permit reads and writes) or `LOCK=SHARED` (permit reads). The operation halts immediately if the requested level of concurrency is not available.

* To compare performance between algorithms, run a statement with `ALGORITHM=INSTANT`, `ALGORITHM=INPLACE` and `ALGORITHM=COPY`. You can also run a statement with the [`old_alter_table`](server-system-variables.html#sysvar_old_alter_table) configuration option enabled to force the use of `ALGORITHM=COPY`.

* To avoid tying up the server with an [`ALTER TABLE`](alter-table.html) operation that copies the table, include `ALGORITHM=INSTANT` or `ALGORITHM=INPLACE`. The statement halts immediately if it cannot use the specified algorithm.

