Adding a new column should be fast, safe, and predictable. In many systems, it can be slow or block traffic. Bad planning leads to downtime, corrupted data, or costly rollbacks. It does not have to be this way.
A new column definition is simple: its name, data type, constraints, and default value. But under the hood, the database must alter internal structures. In SQL databases like PostgreSQL, ALTER TABLE ADD COLUMN with a default value can lock writes while it rewrites every row. MySQL’s ALTER TABLE may rebuild the table. On large datasets, either can take minutes or hours, consuming CPU and I/O.
The safest method is to add the column without a default, then backfill in batches. First, add it as nullable with no default. Then use small, incremental updates that run in the background without locking the table. Once the data is in place, change the default for new rows. If the column must be NOT NULL, enforce that after the backfill completes. This migration strategy prevents blocking and lets you deploy without user impact.