Adding a new column sounds simple, but in live systems it can be dangerous. The wrong step can block writes, lock rows, or trigger downtime. On modern distributed databases, schema changes play out differently than on a single-node server. Latency spikes, replication delays, and migration speed matter. The key is to plan for zero-downtime changes.
In SQL, ALTER TABLE is the starting point. For example:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP NULL;
In Postgres, this specific alter is cheap if it doesn’t require rewriting all rows. But changing data types, default values, or NOT NULL constraints may be expensive. Always check the execution plan and system catalog before applying changes.
For MySQL, adding a column with INSTANT or ONLINE modes in recent versions can avoid full table copies. Use ALGORITHM=INSTANT if the storage engine allows. For large datasets, run the migration on a staging environment first and measure the timing.