Adding a new column sounds simple, but the wrong approach can lock tables, block writes, and stall production. The right process keeps your system online while making the schema change fast and safe. This is where planning and precision matter.
First, decide on the column name, type, and default. Avoid expensive defaults on large tables; they trigger full rewrites. If possible, allow NULL during creation to skip heavy locking. You can backfill later in controlled batches.
Second, choose the migration method. For small tables, a direct ALTER TABLE ADD COLUMN may be fine. For large, high-traffic tables, use an online schema change tool such as pt-online-schema-change or gh-ost. These tools copy data into a shadow table with the new column, keeping reads and writes flowing.
Third, handle backfill carefully. Use chunked updates with limits to avoid saturating CPU, I/O, or replication. Monitor query performance and replication lag during the process. Pause if metrics spike.