Adding a new column seems simple. It rarely is. The wrong approach locks tables, stalls writes, or corrupts data under load. The right approach depends on scale, engine, and downtime tolerance.
In PostgreSQL, ALTER TABLE ADD COLUMN is metadata-only if you add a nullable column without a default. That’s instant, even with billions of rows. But adding a default value forces a full table rewrite. In MySQL, behavior changes between versions—recent releases can add a column instantly if it’s nullable and without default, but older versions rewrite the table. Always check your database’s documentation and test on production-like data volumes.
For production systems with high write rates, break the change into phases. First, add the new column as nullable with no default. Deploy code that writes to both old and new columns. Backfill in small batches during off-peak hours to avoid blocking queries. Only after the backfill completes should you enforce constraints or set defaults.