The schema was live, the deploy had shipped, but the data was already falling behind. The fix was simple: add a new column.
Creating a new column in a database table should be fast, safe, and repeatable. Yet in high-traffic systems, mistakes compound. An ALTER TABLE command can lock writes or blow past your maintenance window. Choosing the right approach matters.
In MySQL and PostgreSQL, adding a column with a default value can rewrite the whole table. This triggers downtime on large datasets. To avoid this, add the column without a default, then backfill in small batches. Finally, set the default for future writes. This pattern prevents table-wide locks that stall production traffic.
For analytics tables, a nullable new column is often enough. For transactional systems, prepare a deploy script and test it against production-sized data. Check the query plan and monitor disk I/O during the migration. Measure first, execute second.