The query ran fast, but the schema did not. You looked at the table. It needed a new column.
Adding a new column sounds simple. In production, it can be complex. Migrations can lock tables. Locks block writes. Latency spikes. Users feel it. The wrong approach can turn a routine change into downtime.
First, define the column. Set its type and constraints. Decide if it allows nulls. If you default to NOT NULL with a value, the database may rewrite the entire table. For large datasets, that’s dangerous. Use NULL first. Backfill in batches. Then add constraints later.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is fast if you do not force a default rewrite. In MySQL, adding a column can still require a table copy, depending on the engine. Always test migrations in a staging environment. Check execution plans. Measure how long it takes on real data, not guesses.