The database was ready. The schema was locked. Then the business team said they needed a new column.
Adding a new column seems simple. It isn’t. A careless change can lock tables, burn CPU, and stall production. The right approach depends on the size of the table, the database engine, and uptime requirements.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast if you add a nullable column without a default. This is metadata-only and won’t rewrite the table. But adding a column with a default value rewrites every row. On large tables, this locks writes and reads until it finishes. The safe pattern is to add the column as nullable, backfill in batches, then set the default.
In MySQL, ALTER TABLE often copies the table under the hood unless you use ALGORITHM=INPLACE or ALGORITHM=INSTANT (introduced in newer versions). These avoid a full table re-copy, but watch out for engine-specific limitations. Always check the execution plan before running on production.