The query ran fast, but the schema was already wrong. You needed a new column, and every second you waited made the cost steeper.
Adding a new column should not be an afterthought. It changes storage, indexing, queries, and application logic. In SQL, ALTER TABLE ... ADD COLUMN is the basic tool. But in production, table size and lock timing matter. On large datasets, a blocking schema change can stall traffic. Online DDL migrations, shadow tables, and zero-downtime deploys prevent outages.
When you add a new column, decide its data type and nullability up front. A nullable column can be added faster, but it may invite inconsistent data. A non-null column with a default forces the database to write a value for every row. This can trigger long writes and lock contention. For Postgres, ADD COLUMN ... DEFAULT was optimized in newer versions to avoid rewriting the whole table. MySQL users rely on ALGORITHM=INPLACE or external tools like gh-ost.