When adding a new column to a database, the decision is rarely simple. Schema changes touch live code paths, alter query plans, and can block writes. A careless ALTER TABLE can take production down. A careful change can enable new features and cut query time in half.
A new column should serve a defined purpose. Start with the exact data type and constraints. Use NOT NULL only when you can backfill without guesswork. If storage is large or access is frequent, consider compression or indexing trade-offs.
Adding the column in PostgreSQL with zero downtime requires ALTER TABLE ... ADD COLUMN only if it’s a lightweight metadata change. In MySQL, this might lock the table depending on the version and engine. For large datasets, use a migration tool that runs batched updates and maintains replication health.
Backfill the new column in controlled steps. Run queries in smaller transactions to avoid long locks and transaction bloat. Monitor replication lag during the process. Once filled, create any needed indexes online if supported by your database version.