A new column can be trivial or dangerous. It depends on how you do it. In a database under load, schema changes can lock writes, slow reads, and throw errors across services. You need a precise approach.
First, define the purpose of the new column. Decide on type, nullability, and default values. For relational databases like PostgreSQL or MySQL, choose defaults carefully; without them, migrations can fail or cause downtime.
In PostgreSQL, adding a nullable column is fast:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This runs as metadata-only in most cases. But adding a NOT NULL with a default will rewrite the table. On large datasets, that can crush performance. The safe play is:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
UPDATE users SET last_login = NOW() WHERE last_login IS NULL;
ALTER TABLE users ALTER COLUMN last_login SET NOT NULL;
In MySQL, behavior depends on engine and version. On InnoDB, most additions lock the table. Use ALGORITHM=INPLACE or INSTANT when supported: