The query hit the database like a hammer, but the table wasn’t ready. You needed a new column, and you needed it without breaking production.
Adding a new column sounds simple. In practice, it can trigger locks, slow queries, and bring down services if done wrong. Modern databases provide tools to add columns without downtime, but the strategy depends on size, workload, and schema constraints.
In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward for small tables. For large datasets, you may want to add the column as nullable, avoid defaults that rewrite the table, and backfill in batches. MySQL’s ALGORITHM=INPLACE and LOCK=NONE can reduce blocking, but only for certain column types and versions. In distributed systems, schema changes need to coordinate across replicas to avoid replication lag or conflicts.