Adding a new column should be fast, predictable, and safe. When schema changes lock tables, block writes, or slow reads, the impact ripples through the system. The key is to choose the right approach for your database, workload, and deployment constraints.
In SQL, a new column can be added with a simple ALTER TABLE statement:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
But in production, that is rarely the whole story. Schema migrations must be managed to avoid downtime and data loss. For large tables, adding a new column may rewrite the entire table, consuming CPU, I/O, and blocking other queries.
Modern systems use online schema changes to mitigate risk. MySQL has ALGORITHM=INPLACE and ALGORITHM=INSTANT options. PostgreSQL can add most new columns instantly if they allow NULL or have a constant default. If the new column requires a non-null default, the database may rewrite the table, so batching or backfilling data in controlled steps is safer.