The query finished in under a second, but the output looked wrong. A missing value exposed a flaw in the schema. The fix was obvious: add a new column.
In modern systems, adding a new column is not just a trivial syntax change. It can cascade through APIs, services, and pipelines. In SQL, the base command is simple:
ALTER TABLE table_name ADD COLUMN column_name data_type;
Yet the consequence is rarely simple. Adding a new column changes your data model. It requires rethinking indexes, defaults, and nullability. If the column will be queried often, create the index at the same time to avoid hot migrations later. If it will hold critical data, enforce constraints now rather than retrofitting them when bugs appear downstream.
When working with millions of rows, plan for migration strategy. Online schema change tools like gh-ost or pt-online-schema-change can prevent downtime. Always test migrations on staging with production-sized data before running them live.