The quick column adding feature allows you to quickly add columns to a big table by only modifying the data dictionary, which eliminates the need of data replication during column adding and greatly reduces the column adding time for big tables and the impact on the system.
This feature is suitable for adding columns to a table with a high volume of data.
In tests with a table of 5 GB data, the time for adding a column is reduced from 40 seconds to below 1 second.
INSTANT ADD COLUMN syntax
algorithm=instant clause to
ALTER TABLE to add a column as follows:
ALTER TABLE t1 ADD COLUMN c INT, ADD COLUMN d INT DEFAULT 1000, ALGORITHM=INSTANT;
innodb_alter_table_default_algorithm parameter is added, which can be set to
This parameter is
inplace by default and can be configured to adjust the default algorithm of
ALTER TABLE as follows:
If no algorithm is specified, the default algorithm configured by this parameter will be used for
ALTER TABLE operations.