The query finished in under five milliseconds, but the schema was wrong. The table needed a new column, and the clock was running.
Adding a new column sounds simple until it’s the thing holding up a deployment. In SQL, the basics are clear:
ALTER TABLE users
ADD COLUMN last_login TIMESTAMP;
This works in development. In production, the truth is harder. Adding a new column can lock a table, block writes, and cause downtime. Small changes at high scale can break SLAs.
For PostgreSQL, ALTER TABLE ... ADD COLUMN is fast if it includes a default of NULL. But adding a column with a NOT NULL constraint and a default value will rewrite the table. On large datasets, this can take minutes or hours. For MySQL, online DDL with ALGORITHM=INPLACE or ALGORITHM=INSTANT (as of MySQL 8.0.12) avoids table copies when adding nullable columns without defaults.