Adding a new column sounds simple—until you face production-scale data. A poorly executed ALTER TABLE can lock rows, spike CPU, and stall requests under load. The right approach depends on your database engine, data volume, and uptime requirements.
In PostgreSQL, small tables can handle a new column instantly if you add it without a default and allow nulls. For larger tables, adding a default forces a table rewrite, which can block transactions. To avoid downtime, first add the column as null, then backfill in controlled batches, and finally apply constraints or defaults in a separate migration.
MySQL behaves differently. Adding a new column often involves creating a copy of the table and swapping it in, which can disrupt writes. Online schema change tools like gh-ost or pt-online-schema-change can help execute the migration without blocking traffic.