The query ran, the logs blinked, and the schema was already out of date. A new column was the only way forward.
Adding a new column sounds simple, but in production systems it demands precision. One wrong move can lock tables, block traffic, or trigger costly downtime. The right approach starts with understanding your database engine’s strengths and limits.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast when adding a nullable column without a default. This avoids a full table rewrite. In MySQL, the same operation can be instant with ALGORITHM=INSTANT on recent versions, but earlier releases may still copy the table. In distributed systems like CockroachDB, adding a new column can be asynchronous to reduce impact, but you must plan for schema propagation across nodes.
Always consider indexes. A new column without proper indexing can break query performance. If you plan to filter or join on it, design the index immediately after adding the field. But never build the index during peak load — schedule it during low-traffic windows.