Add a column to a table of any size in seconds, regardless of table size.
PolarDB for MySQL uses the INSTANT algorithm for this DDL operation. It modifies only metadata in the data dictionary — no historical data is modified or copied, and the table is never rebuilt.
Supported versions
| Version | Minimum revision | Notes |
|---|---|---|
| PolarDB for MySQL 8.0 | Any | Enabled by default. No configuration required. |
| PolarDB for MySQL 5.7 | 5.7.1.0.6 | Enable the loose_innodb_support_instant_add_column parameter before use. |
| PolarDB for MySQL 5.6 | 5.6.1.0.43 | In canary release. Request access via the Quota Center using quota polardb_mysql_iac_56. |
To check your cluster's revision number, see checking the version number.
Limitations
| Limitation | Details |
|---|---|
| Column position | The new column must be the last column in the table. |
| Virtual columns | Supported on 8.0. Not supported on 5.6 or 5.7. |
| Partitioned tables | Not supported on 5.6. Supported on 5.7 and 8.0. On 5.7, this is in canary release — request access via the Quota Center using quota polarM_57_iac_on_partition_table. |
| Full-text indexes | Tables with full-text indexes are not supported. |
| Compressed tables | Tables with ROW_FORMAT=COMPRESSED are not supported. |
| Tables with In-Memory Column Indexes (IMCI) | On 8.0.1.1.42 and earlier, or 8.0.2.2.23 and earlier: set imci_enable_add_column_instant_ddl to ON. When enabled, instant column addition triggers a silent background rebuild of the IMCI. The IMCI is unavailable during rebuilding. On 8.0.1.1.42 and later, or 8.0.2.2.23 and later: set imci_enable_add_column_instant_ddl to OFF. |
| Tables with implicit primary keys | Tables with implicit_primary_key enabled require a custom primary key. |
| Combined DDL statements | Instant column addition cannot be combined with other DDL operations (such as adding an index) in the same ALTER TABLE statement. |
Prerequisites
Before you begin, ensure that you have:
A PolarDB for MySQL cluster running a supported version
For PolarDB for MySQL 5.6: quota access via the Quota Center
For PolarDB for MySQL 5.7: the
loose_innodb_support_instant_add_columnparameter set toON
Enable instant column addition (5.6 and 5.7 only)
PolarDB for MySQL 8.0 clusters support instant column addition by default. For 5.6 and 5.7 clusters, enable the following parameter:
| Parameter | Level | Description |
|---|---|---|
loose_innodb_support_instant_add_column | Global | Enables or disables instant column addition. Valid values: ON (enabled) and OFF (default, disabled). |
For instructions on setting parameters, see Enable a parameter.
Add a column instantly
Force the INSTANT algorithm
Specify ALGORITHM=INSTANT to ensure the operation uses the INSTANT algorithm:
ALTER TABLE <table_name> ADD COLUMN <column_name> int, ALGORITHM=INSTANT;If the cluster or table does not support instant column addition, the statement returns:
ERROR 0A000: ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY/INPLACE.If you see this error, check that loose_innodb_support_instant_add_column is enabled and review the Limitations.
Let PolarDB select the algorithm automatically
Omit the ALGORITHM clause or specify ALGORITHM=DEFAULT to let PolarDB select the fastest available algorithm. PolarDB evaluates algorithms in this order: INSTANT > INPLACE > COPY.
ALTER TABLE <table_name> ADD COLUMN <column_name> int, ALGORITHM=DEFAULT;
ALTER TABLE <table_name> ADD COLUMN <column_name> int;Verify that the INSTANT algorithm was used
PolarDB for MySQL 5.6 and 5.7
Query the INNODB_SYS_INSTANT_COLUMNS table in INFORMATION_SCHEMA. This table stores column names, ordinal positions, and default values (in binary format) for columns added using the INSTANT algorithm:
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INSTANT_COLUMNS;If you later run a DDL operation that triggers a table rebuild (such as OPTIMIZE TABLE), PolarDB physically rebuilds the table. The INSTANT columns are converted to regular columns and their data is fully retained. The corresponding records are removed from INNODB_SYS_INSTANT_COLUMNS.
PolarDB for MySQL 8.0
Query INFORMATION_SCHEMA.INNODB_COLUMNS and check the has_default column. A value of 1 indicates the column was added using the INSTANT algorithm:
SELECT * FROM INFORMATION_SCHEMA.INNODB_COLUMNS
WHERE TABLE_ID = (
SELECT TABLE_ID FROM INFORMATION_SCHEMA.INNODB_TABLES
WHERE NAME = "<database_name>/<table_name>"
);What's next
Support for DDL in PolarDB for MySQL — full reference for DDL algorithms supported by PolarDB for MySQL
If you have questions about DDL operations, contact technical support
Contact us
If you have any questions about DDL operations, please contact technical support.