The query came in without warning: a new column had to be added. The system was live. Traffic was steady. There was no room for downtime.
Adding a new column sounds simple, but in production systems it can trigger cascading risks—locks, degraded performance, schema drift. How you handle it depends on the database engine, the scale of your tables, and how you deploy schema changes.
In PostgreSQL, running ALTER TABLE ADD COLUMN is straightforward for small datasets. The command is fast when adding a nullable column without a default. But with defaults or not-null constraints, the database rewrites every row, which can block queries. For MySQL, the behavior depends on the storage engine. InnoDB can apply some column additions as an online DDL, but others require a table rebuild.
If you need a new column in a high-traffic environment, minimize the impact. First, add the column without a default and allow nulls. Then backfill data in controlled batches. Once complete, add constraints or defaults. This staged approach prevents long locks and keeps the application responsive.