The query hit the database like a hammer, but the data wasn’t there. You needed a new column.
Adding a new column sounds simple until it collides with production load, complex indexes, and unpredictable migrations. Schema changes can stall queries, lock tables, or break deployments if done without a plan. Speed, safety, and zero downtime are the goals. The wrong approach can ripple through every layer of your system.
A new column in PostgreSQL, MySQL, or any relational database is more than an ALTER TABLE command. On small tables, the operation can be near-instant. On large tables, especially with high write traffic, it’s a live surgery. For PostgreSQL, ALTER TABLE ADD COLUMN is fast for null-default columns, because it stores metadata rather than rewriting data. But adding a non-null column with a default value triggers a full table rewrite. In MySQL, online DDL capabilities vary by storage engine, with InnoDB offering certain non-blocking operations but still requiring careful sequencing in production.