Adding a new column sounds simple. It rarely is. In production systems, it can block deploys, lock tables, and slow queries. Done wrong, it kills performance. Done right, it’s invisible and safe.
First, confirm why the new column is needed. Avoid storing data you can compute or fetch on demand. Each column changes how the database stores rows and how your application reads them.
When the decision is clear, plan the migration. In SQL databases, ALTER TABLE ADD COLUMN is straightforward on small datasets but dangerous on large ones. Some databases rebuild the entire table. Others allow fast in-place adds. Check your engine’s documentation and test on a replica.
For PostgreSQL, adding a nullable column with a default that is not constant will rewrite every row. Avoid this by adding the column without a default, then updating in batches. In MySQL, some storage engines handle adds online, but verify with ALGORITHM=INPLACE or ALGORITHM=INSTANT where possible.