In most systems, adding a column is simple in theory but dangerous in practice. Schema changes can lock tables, block queries, or cause downtime on high-traffic applications. A poorly timed ALTER TABLE can ripple outages across a stack. Yet the demand for new columns is constant—tracking user preferences, storing new metadata, enabling new features, or meeting compliance requirements.
A new column can be added either as a blocking operation or through an online migration. Blocking changes halt writes until the operation finishes, which can be quick for small tables but catastrophic for large ones. Online migrations run in the background, copying data into the modified schema before swapping it in. This mitigates downtime but adds complexity.
When adding a new column, consider default values and nullability. Setting a default on a large table can trigger a rewrite of every row. In PostgreSQL, adding a nullable column without a default is nearly instant. You can then backfill values in smaller batches to avoid long locks. In MySQL, the performance impact depends on the storage engine and version; some allow instant adds for certain column types.