Adding a new column to a production database looks simple in code. One line in a migration file. One push to main. But the hidden cost lies in locking tables, rewriting data files, and invalidating caches. Depending on the engine—PostgreSQL, MySQL, or a cloud-managed service—the operation can be instant or bring down your API.
For PostgreSQL, ALTER TABLE ADD COLUMN is usually fast for NULLable fields without defaults. The server just updates metadata. But the moment you set a default that’s not NULL, it writes to every row. On a table with millions of rows, that can block writes for minutes or hours. In MySQL, even metadata-only operations can vary by version and storage engine, and some changes still require a full table rebuild.
To manage risk, create the new column with a NULL default, deploy, then backfill in small batches. Use feature flags to avoid referencing it until the data is ready. Test the migration on a staging snapshot equal in size to production. Watch for replication lag and storage spikes.