The query returned fast, but the schema had shifted. A new column appeared, unannounced.
Adding a new column to a production database is never trivial. It touches schema design, query performance, and application logic. A poorly executed change can lock tables, slow queries, or break services. The right approach depends on the database engine, data volume, and uptime requirements.
In PostgreSQL, you can add a new column with:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This is instant for most cases if no default is set. But with a default value, PostgreSQL may rewrite the whole table, blocking reads and writes. To avoid downtime, first add the column without a default, then update rows in batches, and finally set the default once data is backfilled.
In MySQL, ALTER TABLE often rebuilds the table. For large datasets, consider ALGORITHM=INPLACE or tools like gh-ost and pt-online-schema-change to add a new column without locking. Always test on a clone of production data to measure execution time before running live.