Adding a new column sounds simple, but in real systems it can be risky. Schema changes affect read queries, write performance, and migrations. The wrong approach can lock tables, block transactions, or spike CPU. The goal is to add the new column safely and predictably, without impacting uptime.
First, choose the right DDL strategy. For small tables, a direct ALTER TABLE ADD COLUMN may work. For large datasets, use an online schema change tool like gh-ost or pt-online-schema-change. These tools copy data to a shadow table, apply the change, then swap in the new version, avoiding long locks.
Second, set clear defaults. If your new column requires a value, decide whether to backfill immediately or allow nulls and populate in batches. Backfills on large tables must be performed incrementally to prevent replication lag and performance degradation.
Third, version your application code around the schema change. Roll out support for the new column in stages: