The new column wasn’t in the plan, but now it’s the bottleneck.
Adding a new column to a production database sounds simple. It rarely is. The wrong approach can lock tables, block writes, and slow everything down. Done right, it’s seamless. Done wrong, it’s an outage.
The first step is understanding the database engine you use. In PostgreSQL, ALTER TABLE ... ADD COLUMN can be instant for nullable fields with default NULL. But adding a non-null column with a default forces a full table rewrite. MySQL behaves differently; older versions rebuild the table on any new column, while newer ones with Instant Add Column support handle some cases without a copy.
If the column is large, indexed, or part of critical queries, you need a plan beyond the migration script. Consider backfilling in chunks, creating the column as nullable, and then updating data gradually before enforcing constraints. Deploy this in stages: add column, backfill in batches, lock in constraints when safe. In very large datasets, use online schema change tools like gh-ost for MySQL or logical replication strategies in PostgreSQL.