A new column is one of the most common schema changes in SQL, yet it can break production if not handled with precision. Whether in PostgreSQL, MySQL, or SQLite, adding a column touches both storage layout and query plans. Done right, it’s fast and safe. Done wrong, it locks tables, drops caches, and spikes CPU.
The first step is understanding how your database handles schema changes. In PostgreSQL, ALTER TABLE ADD COLUMN is metadata-only if you provide a default of NULL. But if you specify a non-null default, it rewrites the table. In MySQL, the process can lock writes unless using ALGORITHM=INPLACE when available. SQLite rewrites the table entirely for most changes.
For large datasets, add the new column without defaults. Then backfill in controlled batches, avoiding long locks and replication lag. Use indexed writes only after the backfill completes to prevent index bloat. Always test on a production-size replica to measure timing.