Adding a new column sounds simple, but in production systems it can go wrong fast. Schema changes can lock tables, block queries, and spike latency. The key is knowing which approach will keep your service alive while the database evolves under load.
The first check is the database engine. PostgreSQL, MySQL, and others handle ALTER TABLE ADD COLUMN differently. In PostgreSQL, adding a nullable column with no default is instant. Adding a column with a default value rewrites the table in older versions, but is fast and metadata-only in versions 11 and later. MySQL, depending on the storage engine, may still require a full table rebuild.
For large tables, avoid defaults during the initial migration. Add the column as nullable, deploy, then backfill in small batches. Once data is consistent, enforce NOT NULL in a separate migration. This reduces lock time and helps prevent downtime.
Indexing the new column requires more care. Building an index on an active table can saturate IO and CPU. Use concurrent index creation features if the engine supports them. Staging the index after data backfill avoids building indexes over empty fields.