Adding a new column is one of the most common schema changes in production databases. Done poorly, it can lock tables, block writes, or cause downtime. Done right, it is seamless and safe. The process comes down to understanding your database engine, planning the migration path, and executing in a way that does not disrupt live traffic.
In PostgreSQL, adding a nullable column with no default is instant. Adding a column with a default value pre-13 rewrites the entire table, which can be slow. In MySQL, adding a column may trigger a table copy depending on storage engine, column type, and the ALTER TABLE syntax you use. Knowing these details is critical to avoiding performance hits.
When you add a new column, analyze the impact on indexes, queries, and replication. If the column is required, consider a two-step approach: create it as nullable, backfill the data asynchronously, then add a NOT NULL constraint. This reduces the risk of blocking operations. For large datasets, perform backfills in small batches to keep transactions short and load low.