The query returns fast, but the schema is wrong. You need a new column, and you need it without breaking production.
A new column sounds simple. Add it to the table. Migrate the data. Deploy. But one mistake here can trigger downtime, data drift, or a rollback that costs hours. At scale, the strategy matters more than the syntax.
When adding a new column in a relational database, start with a non-blocking migration. Add the column as nullable. Avoid default values that rewrite the table. This keeps the operation online for large datasets. Once deployed, backfill data in small batches. Use versioned application code so reads and writes handle both old and new states. Only after the backfill should you enforce NOT NULL constraints or indexed keys.
In PostgreSQL, ALTER TABLE ADD COLUMN is instant when nullable without defaults. In MySQL, large tables may still lock, so use online DDL or tools like gh-ost. In distributed SQL, check the vendor’s documentation—implementation details vary. Always stage schema changes through test environments with authentic data volumes.