All pages
Powered by GitBook
1 of 1

Loading...

InnoDB Online DDL Operations with the INSTANT Alter Algorithm

Discover the INSTANT algorithm, which modifies table metadata without rebuilding the table, enabling extremely fast schema changes like adding columns.

Column Operations

ALTER TABLE ... ADD COLUMN

In and later, InnoDB supports adding columns to a table with set to INSTANT if the new column is the last column in the table. See for more information. If the table has a hidden FTS_DOC_ID column is present, then this is not supported.

In and later, InnoDB supports adding columns to a table with set to INSTANT, regardless of where in the column list the new column is added.

When this operation is performed with set to INSTANT, the tablespace file will have a non-canonical storage format. See for more information.

With the exception of adding an column, this operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example, this succeeds:

And this succeeds in and later:

This applies to for tables.

See for more information.

ALTER TABLE ... DROP COLUMN

In and later, InnoDB supports dropping columns from a table with set to INSTANT. See for more information.

When this operation is performed with set to INSTANT, the tablespace file will have a non-canonical storage format. See for more information.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

This applies to for tables.

ALTER TABLE ... MODIFY COLUMN

This applies to for tables.

Reordering Columns

In and later, InnoDB supports reordering columns within a table with set to INSTANT. See for more information.

When this operation is performed with set to INSTANT, the tablespace file will have a non-canonical storage format. See for more information.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

Changing the Data Type of a Column

InnoDB does not support modifying a column's data type with set to INSTANT in most cases. There are some exceptions:

  • InnoDB supports increasing the length of VARCHAR columns with set to INSTANT, unless it would require changing the number of bytes requires to represent the column's length. A VARCHAR column that is between 0 and 255 bytes in size requires 1 byte to represent its length, while a VARCHAR column that is 256 bytes or longer requires 2 bytes to represent its length. This means that the length of a column cannot be increased with set to INSTANT if the original length was less than 256 bytes, and the new length is 256 bytes or more.

  • In and later, InnoDB supports increasing the length of VARCHAR

The supported operations in this category support the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example, this fails:

But this succeeds because the original length of the column is less than 256 bytes, and the new length is still less than 256 bytes:

But this fails because the original length of the column is between 128 bytes and 255 bytes, and the new length is greater than 256 bytes:

But this succeeds in and later because the table has ROW_FORMAT=REDUNDANT:

And this succeeds in and later because the table has ROW_FORMAT=DYNAMIC and the column's original length is 127 bytes or less:

And this succeeds in and later because the table has ROW_FORMAT=COMPRESSED and the column's original length is 127 bytes or less:

But this fails even in and later because the table has ROW_FORMAT=DYNAMIC and the column's original length is between 128 bytes and 255 bytes:

Changing a Column to NULL

In and later, InnoDB supports modifying a column to allow values with set to INSTANT if the table option is set to . See for more information.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

Changing a Column to NOT NULL

InnoDB does not support modifying a column to not allow values with set to INSTANT.

For example:

Adding a New ENUM Option

InnoDB supports adding a new option to a column with set to INSTANT. In order to add a new option with set to INSTANT, the following requirements must be met:

  • It must be added to the end of the list.

  • The storage requirements must not change.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example, this succeeds:

But this fails:

Adding a New SET Option

InnoDB supports adding a new option to a column with set to INSTANT. In order to add a new option with set to INSTANT, the following requirements must be met:

  • It must be added to the end of the list.

  • The storage requirements must not change.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example, this succeeds:

But this fails:

Removing System Versioning from a Column

In and later, InnoDB supports removing from a column with set to INSTANT. In order for this to work, the system variable must be set to KEEP. See for more information.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

ALTER TABLE ... ALTER COLUMN

This applies to for tables.

Setting a Column's Default Value

InnoDB supports modifying a column's value with set to INSTANT.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

Removing a Column's Default Value

InnoDB supports removing a column's value with set to INSTANT.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

ALTER TABLE ... CHANGE COLUMN

InnoDB supports renaming a column with set to INSTANT, unless the column's data type or attributes changed in addition to the name.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example, this succeeds:

But this fails:

This applies to for tables.

Index Operations

ALTER TABLE ... ADD PRIMARY KEY

InnoDB does not support adding a primary key to a table with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... DROP PRIMARY KEY

InnoDB does not support dropping a primary key with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... ADD INDEX and CREATE INDEX

This applies to and for tables.

Adding a Plain Index

InnoDB does not support adding a plain index to a table with set to INSTANT.

For example, this fails:

And this fails:

Adding a Fulltext Index

InnoDB does not support adding a index to a table with set to INSTANT.

For example, this fails:

And this fails:

Adding a Spatial Index

InnoDB does not support adding a index to a table with set to INSTANT.

For example, this fails:

And this fails:

ALTER TABLE ... ADD FOREIGN KEY

InnoDB does not support adding foreign key constraints to a table with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... DROP FOREIGN KEY

InnoDB supports dropping foreign key constraints from a table with set to INSTANT.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

This applies to for tables.

Table Operations

ALTER TABLE ... AUTO_INCREMENT=...

InnoDB supports changing a table's value with set to INSTANT.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

This applies to for tables.

ALTER TABLE ... ROW_FORMAT=...

InnoDB does not support changing a table's with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... KEY_BLOCK_SIZE=...

InnoDB does not support changing a table's with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... PAGE_COMPRESSED=1 and ALTER TABLE ... PAGE_COMPRESSION_LEVEL=...

In and later, InnoDB supports setting a table's value to 1 with set to INSTANT. InnoDB does not support changing a table's value from 1 to 0 with set to INSTANT.

In these versions, InnoDB also supports changing a table's value with set to INSTANT.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

See for more information.

For example, this succeeds:

And this succeeds:

But this fails:

This applies to and for tables.

ALTER TABLE ... DROP SYSTEM VERSIONING

InnoDB does not support dropping from a table with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... DROP CONSTRAINT

In and later, InnoDB supports dropping a constraint from a table with set to INSTANT. See for more information.

This operation supports the non-locking strategy. This strategy can be explicitly chosen by setting the clause to NONE. When this strategy is used, all concurrent DML is permitted.

For example:

This applies to for tables.

ALTER TABLE ... FORCE

InnoDB does not support forcing a table rebuild with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... ENGINE=InnoDB

InnoDB does not support forcing a table rebuild with set to INSTANT.

For example:

This applies to for tables.

OPTIMIZE TABLE ...

InnoDB does not support optimizing a table with set to INSTANT.

For example:

This applies to for tables.

ALTER TABLE ... RENAME TO and RENAME TABLE ...

InnoDB supports renaming a table with set to INSTANT.

This operation supports the exclusive locking strategy. This strategy can be explicitly chosen by setting the clause to EXCLUSIVE. When this strategy is used, concurrent DML is not permitted.

For example, this succeeds:

And this succeeds:

This applies to and for tables.

Limitations

Limitations Related to Generated (Virtual and Persistent/Stored) Columns

do not currently support online DDL for all of the same operations that are supported for "real" columns.

See for more information on the limitations.

Non-canonical Storage Format Caused by Some Operations

Some operations cause a table's tablespace file to use a non-canonical storage format when the INSTANT algorithm is used. The affected operations include:

These operations require the following non-canonical changes to the storage format:

  • A hidden metadata record at the start of the clustered index is used to store each column's value. This makes it possible to add new columns that have default values without rebuilding the table.

  • A in the hidden metadata record is used to store column mappings. This makes it possible to drop or reorder columns without rebuilding the table. This also makes it possible to add columns to any position or drop columns from any position in the table without rebuilding the table.

  • If a column is dropped, old records will contain garbage in that column's former position, and new records are written with values, empty strings, or dummy values.

This non-canonical storage format has the potential to incur some performance or storage overhead for all subsequent DML operations. If you notice some issues like this and you want to normalize a table's storage format to avoid this problem, then you can do so by forcing a table rebuild by executing with set to INPLACE:

However, keep in mind that there are certain scenarios where you may not be able to rebuild the table with set to INPLACE. See for more information on those cases. If you hit one of those scenarios, but you still want to rebuild the table, then you would have to do so with set to COPY.

Known Bugs

There are some known bugs that could lead to issues when an InnoDB DDL operation is performed using the algorithm. This algorithm will usually be chosen by default if the operation supports the algorithm.

The effect of many of these bugs is that the table seems to forget that its tablespace file is in the .

If you are concerned that a table may be affected by one of these bugs, then your best option would be to normalize the table structure. This can be done by rebuilding the table:

If you are concerned about these bugs, and you want to perform an operation that supports the algorithm, but you want to avoid using that algorithm, then you can set the algorithm to and add the FORCE keyword to the statement:

Closed Bugs

  • : This bug could cause a table to become corrupt if a column was added instantly. It is fixed in and .

  • : This bug could cause a table to become corrupt if a column was dropped instantly. It is fixed in .

  • : This bug could cause a table to become corrupt during page reorganization if a column was added instantly. It is fixed in and .

This page is licensed: CC BY-SA / Gnu FDL

columns with
set to INSTANT with no restrictions if the
table option is set to
. See
for more information.
  • In and later, InnoDB also supports increasing the length of VARCHAR columns with ALGORITHM set to INSTANT in a more limited manner if the ROW_FORMAT table option is set to COMPACT, DYNAMIC, or COMPRESSED. In this scenario, the following limitations apply:

    • The length can be increased with ALGORITHM set to INSTANT if the original length of the column is 127 bytes or less, and the new length of the column is 256 bytes or more.

    • The length can be increased with set to INSTANT if the original length of the column is 255 bytes or less, and the new length of the column is still 255 bytes or less.

    • The length can be increased with set to INSTANT if the original length of the column is 256 bytes or more, and the new length of the column is still 256 bytes or more.

    • The length can not be increased with set to INSTANT if the original length was between 128 bytes and 255 bytes, and the new length is 256 bytes or more.

    • See for more information.

  • MDEV-19783: This bug could cause a table to become corrupt if a column was added instantly. It is fixed in and
  • MDEV-20090: This bug could cause a table to become corrupt if columns were added, dropped, or reordered instantly. It is fixed in .

  • MDEV-18519: This bug could cause a table to become corrupt if a column was added instantly. It is fixed in MariaDB 10.6.9, , and .

  • MDEV-18519: This bug could cause a table to become corrupt if a column was added instantly. This isn't and won't be fixed in versions less than MariaDB 10.6.

  • ALGORITHM
    MDEV-11369
    ALGORITHM
    ALGORITHM
    Non-canonical Storage Format Caused by Some Operations
    auto-increment
    LOCK
    ALTER TABLE ... ADD COLUMN
    InnoDB
    Instant ADD COLUMN for InnoDB
    ALGORITHM
    MDEV-15562
    ALGORITHM
    Non-canonical Storage Format Caused by Some Operations
    LOCK
    ALTER TABLE ... DROP COLUMN
    InnoDB
    ALTER TABLE ... MODIFY COLUMN
    InnoDB
    ALGORITHM
    MDEV-15562
    ALGORITHM
    Non-canonical Storage Format Caused by Some Operations
    LOCK
    ALGORITHM
    ALGORITHM
    ALGORITHM
    LOCK
    NULL
    ALGORITHM
    ROW_FORMAT
    REDUNDANT
    MDEV-15563
    LOCK
    NULL
    ALGORITHM
    ENUM
    ALGORITHM
    ENUM
    ALGORITHM
    LOCK
    SET
    ALGORITHM
    SET
    ALGORITHM
    LOCK
    system versioning
    ALGORITHM
    system_versioning_alter_history
    MDEV-16330
    LOCK
    ALTER TABLE ... ALTER COLUMN
    InnoDB
    DEFAULT
    ALGORITHM
    LOCK
    DEFAULT
    ALGORITHM
    LOCK
    ALGORITHM
    LOCK
    ALTER TABLE ... CHANGE COLUMN
    InnoDB
    ALGORITHM
    ALTER TABLE ... ADD PRIMARY KEY
    InnoDB
    ALGORITHM
    ALTER TABLE ... DROP PRIMARY KEY
    InnoDB
    ALTER TABLE ... ADD INDEX
    CREATE INDEX
    InnoDB
    ALGORITHM
    FULLTEXT
    ALGORITHM
    SPATIAL
    ALGORITHM
    ALGORITHM
    ALTER TABLE ... ADD FOREIGN KEY
    InnoDB
    ALGORITHM
    LOCK
    ALTER TABLE ... DROP FOREIGN KEY
    InnoDB
    AUTO_INCREMENT
    ALGORITHM
    LOCK
    ALTER TABLE ... AUTO_INCREMENT=...
    InnoDB
    row format
    ALGORITHM
    ALTER TABLE ... ROW_FORMAT=...
    InnoDB
    KEY_BLOCK_SIZE
    ALGORITHM
    KEY_BLOCK_SIZE=...
    InnoDB
    PAGE_COMPRESSED
    ALGORITHM
    PAGE_COMPRESSED
    ALGORITHM
    PAGE_COMPRESSION_LEVEL
    ALGORITHM
    LOCK
    MDEV-16328
    ALTER TABLE ... PAGE_COMPRESSED=...
    ALTER TABLE ... PAGE_COMPRESSION_LEVEL=...
    InnoDB
    system versioning
    ALGORITHM
    ALTER TABLE ... DROP SYSTEM VERSIONING
    InnoDB
    CHECK
    ALGORITHM
    MDEV-16331
    LOCK
    ALTER TABLE ... DROP CONSTRAINT
    InnoDB
    ALGORITHM
    ALTER TABLE ... FORCE
    InnoDB
    ALGORITHM
    ALTER TABLE ... ENGINE=InnoDB
    InnoDB
    ALGORITHM
    OPTIMIZE TABLE
    InnoDB
    ALGORITHM
    LOCK
    ALTER TABLE ... RENAME TO
    RENAME TABLE
    InnoDB
    Generated columns
    Generated (Virtual and Persistent/Stored) Columns: Statement Support
    Adding a column.
    Dropping a column.
    Reordering columns.
    DEFAULT
    BLOB
    NULL
    ALTER TABLE ... FORCE
    ALGORITHM
    ALGORITHM
    InnoDB Online DDL Operations with ALGORITHM=INPLACE: Limitations
    ALGORITHM
    INSTANT
    non-canonical storage format
    INSTANT
    INPLACE
    ALTER TABLE
    MDEV-20066
    MDEV-20117
    MDEV-19743
    ALGORITHM
    ROW_FORMAT
    REDUNDANT
    MDEV-15563
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ADD COLUMN c VARCHAR(50);
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ADD COLUMN c VARCHAR(50) AFTER a;
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab DROP COLUMN c;
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(50) AFTER a;
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c INT;
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    ) CHARACTER SET=latin1;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(100);
    Query OK, 0 rows affected (0.005 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(255)
    ) CHARACTER SET=latin1;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(256);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(200)
    ) ROW_FORMAT=REDUNDANT;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(300);
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(127)
    ) ROW_FORMAT=DYNAMIC
      CHARACTER SET=latin1;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(300);
    Query OK, 0 rows affected (0.003 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(127)
    ) ROW_FORMAT=COMPRESSED
      CHARACTER SET=latin1;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(300);
    Query OK, 0 rows affected (0.003 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(128)
    ) ROW_FORMAT=DYNAMIC
      CHARACTER SET=latin1;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(300);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50) NOT NULL
    ) ROW_FORMAT=REDUNDANT;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(50) NULL;
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    ) ROW_FORMAT=REDUNDANT;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(50) NOT NULL;
    ERROR 1845 (0A000): ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c ENUM('red', 'green')
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c ENUM('red', 'green', 'blue');
    Query OK, 0 rows affected (0.002 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c ENUM('red', 'green')
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c ENUM('red', 'blue', 'green');
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c SET('red', 'green')
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c SET('red', 'green', 'blue');
    Query OK, 0 rows affected (0.002 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c SET('red', 'green')
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c SET('red', 'blue', 'green');
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50) WITH SYSTEM VERSIONING
    );
    
    SET SESSION system_versioning_alter_history='KEEP';
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab MODIFY COLUMN c VARCHAR(50) WITHOUT SYSTEM VERSIONING;
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ALTER COLUMN c SET DEFAULT 'NO value explicitly provided.';
    Query OK, 0 rows affected (0.003 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50) DEFAULT 'NO value explicitly provided.'
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ALTER COLUMN c DROP DEFAULT;
    Query OK, 0 rows affected (0.002 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab CHANGE COLUMN c str VARCHAR(50);
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab CHANGE COLUMN c num INT;
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
    CREATE OR REPLACE TABLE tab (
       a INT,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION sql_mode='STRICT_TRANS_TABLES';
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ADD PRIMARY KEY (a);
    ERROR 1845 (0A000): ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab DROP PRIMARY KEY;
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try ALGORITHM=COPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ADD INDEX b_index (b);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    CREATE INDEX b_index ON tab (b);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INPLACE';
    ALTER TABLE tab ADD FULLTEXT INDEX b_index (b);
    Query OK, 0 rows affected (0.042 sec)
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ADD FULLTEXT INDEX c_index (c);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INPLACE';
    CREATE FULLTEXT INDEX b_index ON tab (b);
    Query OK, 0 rows affected (0.040 sec)
    
    SET SESSION alter_algorithm='INSTANT';
    CREATE FULLTEXT INDEX c_index ON tab (c);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c GEOMETRY NOT NULL
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ADD SPATIAL INDEX c_index (c);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c GEOMETRY NOT NULL
    );
    
    SET SESSION alter_algorithm='INSTANT';
    CREATE SPATIAL INDEX c_index ON tab (c);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
    CREATE OR REPLACE TABLE tab1 (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50),
       d INT
    );
    
    CREATE OR REPLACE TABLE tab2 (
       a INT PRIMARY KEY,
       b VARCHAR(50)
    );
    
    SET SESSION foreign_key_checks=OFF;
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab1 ADD FOREIGN KEY tab2_fk (d) REFERENCES tab2 (a);
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
    CREATE OR REPLACE TABLE tab2 (
       a INT PRIMARY KEY,
       b VARCHAR(50)
    );
    
    CREATE OR REPLACE TABLE tab1 (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50),
       d INT,
       FOREIGN KEY tab2_fk (d) REFERENCES tab2 (a)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab1 DROP FOREIGN KEY tab2_fk; 
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab AUTO_INCREMENT=100;
    Query OK, 0 rows affected (0.002 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    ) ROW_FORMAT=DYNAMIC;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ROW_FORMAT=COMPRESSED;
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    ) ROW_FORMAT=COMPRESSED
      KEY_BLOCK_SIZE=4;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab KEY_BLOCK_SIZE=2;
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab PAGE_COMPRESSED=1;
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    ) PAGE_COMPRESSED=1
      PAGE_COMPRESSION_LEVEL=5;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab PAGE_COMPRESSION_LEVEL=4;
    Query OK, 0 rows affected (0.004 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    ) PAGE_COMPRESSED=1;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab PAGE_COMPRESSED=0;
    ERROR 1846 (0A000): ALGORITHM=INSTANT is not supported. Reason: Changing table options requires the table to be rebuilt. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    ) WITH SYSTEM VERSIONING;
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab DROP SYSTEM VERSIONING;
    ERROR 1845 (0A000): ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50),
       CONSTRAINT b_not_empty CHECK (b != '')
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab DROP CONSTRAINT b_not_empty;
    Query OK, 0 rows affected (0.002 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab FORCE;
    ERROR 1845 (0A000): ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab ENGINE=InnoDB;
    ERROR 1845 (0A000): ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SHOW GLOBAL VARIABLES WHERE Variable_name IN('innodb_defragment', 'innodb_optimize_fulltext_only');
    +-------------------------------+-------+
    | Variable_name                 | Value |
    +-------------------------------+-------+
    | innodb_defragment             | OFF   |
    | innodb_optimize_fulltext_only | OFF   |
    +-------------------------------+-------+
    2 rows in set (0.001 sec)
    
    SET SESSION alter_algorithm='INSTANT';
    OPTIMIZE TABLE tab;
    +---------+----------+----------+------------------------------------------------------------------------------+
    | Table   | Op       | Msg_type | Msg_text                                                                     |
    +---------+----------+----------+------------------------------------------------------------------------------+
    | db1.tab | optimize | note     | Table does not support optimize, doing recreate + analyze instead            |
    | db1.tab | optimize | error    | ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=INPLACE |
    | db1.tab | optimize | status   | Operation failed                                                             |
    +---------+----------+----------+------------------------------------------------------------------------------+
    3 rows in set, 1 warning (0.002 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    ALTER TABLE tab RENAME TO old_tab;
    Query OK, 0 rows affected (0.008 sec)
    CREATE OR REPLACE TABLE tab (
       a INT PRIMARY KEY,
       b VARCHAR(50),
       c VARCHAR(50)
    );
    
    SET SESSION alter_algorithm='INSTANT';
    RENAME TABLE tab TO old_tab;
    Query OK, 0 rows affected (0.008 sec)
    SET SESSION alter_algorithm='INPLACE';
    ALTER TABLE tab FORCE;
    Query OK, 0 rows affected (0.008 sec)
    SET SESSION alter_algorithm='INPLACE';
    ALTER TABLE tab FORCE;
    Query OK, 0 rows affected (0.008 sec)
    SET SESSION alter_algorithm='INPLACE';
    ALTER TABLE tab ADD COLUMN c VARCHAR(50), FORCE;
    ALGORITHM
    ALGORITHM
    ALGORITHM
    MDEV-15563
    MariaDB 10.3.2
    MariaDB 10.4
    MariaDB 10.4
    MariaDB 10.4
    MariaDB 10.4
    MariaDB 10.4.3
    MariaDB 10.4.3
    MariaDB 10.4.3
    MariaDB 10.4.3
    MariaDB 10.4.3
    MariaDB 10.4.3
    MariaDB 10.3.8
    MariaDB 10.3.10
    MariaDB 10.3.6
    MariaDB 10.3.18
    MariaDB 10.4.8
    MariaDB 10.4.9
    MariaDB 10.3.17
    MariaDB 10.4.7
    MariaDB 10.4.3
    MariaDB 10.3.17
    MariaDB 10.4.7
    MariaDB 10.4.9
    MariaDB 10.7.5
    MariaDB 10.8.4
    MariaDB 10.9.2