The query landed. The dataset was huge. You needed to add a new column fast, without breaking anything, without delays.
A new column sounds simple. In production, it can be risky. Schema changes touch live data. One lock too long and users notice. One bad default and downstream jobs fail. The best engineers plan these changes to be atomic, testable, and reversible.
Start with the schema design. Decide if the new column is nullable or if it needs a default value. For large tables, avoid defaults that rewrite every row. Create the column first, backfill in small batches, then add constraints after the data is ready. This keeps migrations fast and avoids full table locks.
Use transactional DDL if your database supports it. For Postgres, ALTER TABLE ADD COLUMN is generally safe for new nullable columns, but defaults can trigger rewrites. For MySQL, newer versions allow ALGORITHM=INSTANT for many column additions, but always confirm the execution plan before running in production.