Avoiding Downtime with MariaDB Instant ADD COLUMN
Stop blocking your production database with long-running ALTER TABLE commands. Learn how MariaDB's Instant DDL adds columns in milliseconds without rebuilding data.
12 Jun 2026, 00:12 UTC

The Cost of a Simple Schema Change
Adding a column to a table with five hundred million rows sounds trivial until you execute the ALTER TABLE command and realize your application has stopped responding. In traditional database operations, adding a column often triggers a table rebuild (ALGORITHM=COPY), where the engine creates a hidden temporary table, copies every single row, and swaps the files. For large datasets, this means hours of write-blocking and massive I/O spikes.
The takeaway: If you are using MariaDB 10.3 or later, you can add columns to InnoDB tables almost instantaneously, regardless of table size, by leveraging Instant DDL. Instead of rewriting the data on disk, the engine updates the table definition.
How Instant DDL Works Internally
MariaDB implements instant ADD COLUMN by storing the default value in the data dictionary rather than rewriting every row. Existing rows implicitly return the stored default when read, while new rows write the value physically. The operation acquires only a brief metadata lock (MDL) to update the table definition, then releases it—allowing concurrent DML to continue.
Practical Implementation
To ensure you don't accidentally fall back to a blocking copy, use ALGORITHM=INSTANT and LOCK=NONE explicitly. This forces the operation to fail fast if instant mode is not possible.
Run this command on your database client with administrative privileges:
ALTER TABLE orders ADD COLUMN status ENUM('new','processing','shipped') DEFAULT 'new', ALGORITHM=INSTANT, LOCK=NONE;Expected Result: Query OK, 0 rows affected, 0.01 sec. This completes in milliseconds on a massive table where a standard alter would take hours.
When Instant DDL Fails
While powerful, instant ADD COLUMN is not supported in every scenario. The following conditions will trigger a fallback to a blocking rebuild:
- Non-deterministic defaults: Adding a column with a non-constant default like
RAND()orUUID()is rejected for instant mode. - Table Formats: If the table uses
ROW_FORMAT=COMPRESSEDor has aFULLTEXTindex, the operation falls back to COPY. - Partitioning: Instant ADD COLUMN is not supported for partitioned tables prior to MariaDB 10.5.
- Column Position: Adding a column in the middle of the table requires a rebuild.
Verification and Monitoring
To confirm the operation was truly instant, monitor the internal status counters. Run the following:
SHOW STATUS LIKE 'Innodb_instant_alter_column';The value should increment by 1 for each successful instant ADD COLUMN.
Trade-offs and Maintenance
The primary trade-off is that instant ADD COLUMN increases the row size logically. Because the default is materialized on the first UPDATE of that row, subsequent updates to old rows become slightly heavier. Additionally, adding hundreds of instant columns can bloat the data dictionary and slow down table open/close operations.
If your table is read-heavy and has undergone many schema changes, consider a periodic OPTIMIZE TABLE to materialize defaults and defragment the storage.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.