Adding a new column sounds simple. In production, it can be dangerous. Schema changes at scale can lock tables, slow queries, or even cause outages. Choosing the right method means balancing speed, safety, and consistency.
A new column in a relational database changes the structure of a table. The database must record that change in metadata. If the column has a default value that is not NULL, it often triggers a full table rewrite. For large datasets, this can lead to downtime. Avoid that by setting the new column as nullable first, backfilling in batches, then adding constraints after.
In MySQL, ALTER TABLE is blocking by default. Adding a new column to a table with millions of rows can freeze writes. Use tools like pt-online-schema-change or gh-ost to apply the change online, with minimal lock time. These tools copy table data row-by-row into a new table with the updated schema, then swap it in atomically.