The query returned fast, but the schema was wrong. A new column had appeared in the production database.
Adding a new column is never just adding a new column. It changes the shape of your data, the shape of your code, and sometimes the shape of your business logic. Done right, it unlocks features. Done wrong, it breaks deployments, corrupts data, and costs hours in emergency rollbacks.
Start with the definition. In SQL, ALTER TABLE is the command to add a new column. Define the column name, type, constraints, and default values. Every choice affects performance and storage. NULL vs. NOT NULL determines how your app handles missing data. Default values decide whether you can deploy without backfilling.
In PostgreSQL, adding a nullable column without a default is instant, even on large tables. Adding with a default can lock the table. Use DEFAULT in combination with ALTER TABLE ... ADD COLUMN carefully. For large datasets, backfill in smaller batches after adding the column to avoid downtime. In MySQL, defaults and nullability rules differ. Research before production changes.