The query hit the database like a hammer, but the numbers it returned were wrong. The fix was simple: add a new column. It always sounds easy. It never is.
A new column changes the shape of your data. It alters schemas, impacts indexes, and can ripple through APIs, queries, and downstream systems. In relational databases like PostgreSQL, MySQL, or SQL Server, adding a new column means more than just an ALTER TABLE statement. Storage, defaults, and constraints all matter.
In PostgreSQL, ALTER TABLE users ADD COLUMN last_login TIMESTAMP; will be instant if the column allows NULL and has no default. But add a default with NOT NULL, and the operation rewrites the entire table. On large datasets, this can lock writes for minutes or hours. The right approach is often to add the column as nullable, backfill data in batches, then enforce constraints.
In MySQL, especially with InnoDB, version matters. Instant DDL in newer releases can add a new column without copying data, but older versions still require a full table rebuild. Plan migrations with read/write traffic in mind and test on staging with production-like sizes.