Adding a new column sounds simple. In practice, it can break production, block deploys, and trigger costly downtime if handled wrong. Databases under heavy load require careful scheduling, indexing strategy, and rollback plans. Whether you use Postgres, MySQL, or a cloud-managed service, the approach determines if the change rolls out clean or stalls the system.
The first step is to define the column type and default values explicitly. Avoid implicit type casts, as they can lock the table during writes. For large datasets, add the new column without defaults, then backfill data in small batches. This minimizes lock time and keeps queries responsive.
In Postgres, ALTER TABLE ADD COLUMN is transactional, but can still trigger table rewrites if defaults are set. Use ALTER TABLE ... ADD COLUMN NULL, then populate the column via UPDATE with a LIMIT and OFFSET pattern or an indexed cursor. Monitor index update cost before adding constraints.