Adding a new column is one of the most common schema changes in a database. Done right, it’s fast and safe. Done wrong, it locks tables, burns CPU, and disrupts users. The process is simple in theory—alter the table and define the column. In reality, the impact on production can be severe without careful planning.
A new column changes storage layout. Depending on the database engine, it may rewrite the entire table. In MySQL, ALTER TABLE without ALGORITHM=INPLACE can block reads and writes. In PostgreSQL, adding a column with a default value writes it into every existing row. For large datasets, that means long locks and transaction bloat. Understanding the execution path of your database’s ALTER command is non‑negotiable.
Best practice is to make the new column nullable at first. Populate it in batches. Only after the backfill finishes should you enforce NOT NULL or add constraints. This reduces migration time during the first schema change and avoids downtime.