The query returned in under 10 milliseconds, but the schema was already broken. The missing piece was a new column.
Adding a new column should be simple, but in production systems it comes with risk. Schema changes can lock tables, impact performance, or cause downtime. The right approach depends on the database, the size of the table, and the workload it serves.
Start with a clear definition. In SQL, a new column is added with an ALTER TABLE statement. For example:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This command works for most relational databases, including PostgreSQL and MySQL. Yet the impact differs. On small tables, it is instant. On large ones, it can run for minutes, block writes, and consume CPU.
Plan schema changes during low-traffic windows or use online schema migration tools like pt-online-schema-change or gh-ost. In Postgres, ALTER TABLE ... ADD COLUMN without a default value is fast because it only updates metadata. But adding a default forces a full table rewrite, which may stall the system.