Adding a new column seems simple. It isn’t. The right approach depends on your database engine, data size, and uptime requirements. A careless schema change can block queries, lock writes, and drop performance to zero.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast for non-nullable columns without a default, because it updates metadata only. But adding a new column with a default value to a large table will rewrite every row—on production, that’s a problem. MySQL has similar pitfalls depending on storage engine and version.
Zero-downtime strategies matter. For massive datasets, you can add the new column as nullable, backfill in small batches, then apply constraints. Online schema change tools like pt-online-schema-change or native ALGORITHM=INPLACE in MySQL reduce locking. In PostgreSQL, check pg_squeeze or logical replication to roll out changes without halts.