Adding a new column to a production table should be simple. It isn’t. Schema changes can lock rows, spike CPU, and slow queries at the worst possible moment. Every extra byte stored can shift query plans and crash caches. A single migration on a table with millions of rows can block writes and break deploys.
The safest way to add a new column is in small, controlled steps. Start by analyzing table size, index usage, and constraints. Decide whether the column allows NULLs. For large datasets, add the column without a default value first. This avoids full table rewrites. Then backfill values in batches, using a script or job queue, and update indexes after the data is in place.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast if you don’t set a default that needs rewriting old rows. MySQL behaves differently depending on the storage engine and version. Some versions require a full table copy. Use tools like pt-online-schema-change or gh-ost to avoid downtime.