Adding a new column should be simple, but in production systems it’s often risky. Every migration is a potential point of failure. Schema changes that seem trivial can lock tables, block writes, and cause downtime. That’s why creating a new column requires planning, efficient SQL, and atomic operations when possible.
In PostgreSQL, adding a new column is usually fast if it has no default or is nullable:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
If you need a default value, using a constant default is efficient. A computed default or a non-null constraint on a large table can trigger a full table rewrite, which is slow. In MySQL, the process is similar, but older storage engines may rebuild entire tables even for small alterations.
When working with large datasets, run migrations during low-traffic windows or use tools like pt-online-schema-change. Consider adding the column as nullable, backfilling in small batches, and then applying constraints later. This staged approach reduces lock time and risk.