Adding a new column is one of the most common schema changes in any database. It sounds simple. It should be simple. But in production, speed, locking, and data integrity turn a trivial task into a risk point.
A new column can be added in multiple ways, depending on the database engine. With PostgreSQL, ALTER TABLE ADD COLUMN is a direct method. It locks the table for a short time, which can block concurrent writes. MySQL supports ALTER TABLE as well, though older versions require a full table rebuild. Some modern engines like CockroachDB or Amazon Aurora optimize these operations behind the scenes.
Choosing the right data type for a new column matters for both performance and storage. Avoid oversized types. Use NOT NULL only when you can set a default or safely backfill data. For nullable columns, ensure that the consuming application handles nulls without error.
Backfilling data for a new column in a large table should be done in batches. This prevents long-running transactions and reduces replication lag. Many teams pair this with a feature flag rollout in the application layer, enabling reads from the new column only after the backfill is complete.