The query hit the database like a hammer, but the table wasn’t ready. You needed a new column.
Adding a new column is common work, but it can cripple performance if done carelessly. Whether you’re using PostgreSQL, MySQL, or another relational database, the steps matter. Schema changes touch everything: queries, indexes, migrations, and uptime. The safest path is deliberate and tested.
Plan the change. Decide the exact data type. Avoid generic types that waste storage or risk data loss. Set default values where they make sense, but skip them if the initial backfill would lock up the table.
For large tables, add the column without a default, then backfill in small batches. This avoids full table rewrites that block reads and writes. Use a migration tool that supports transactional DDL when possible. If your database engine can’t do it without downtime, schedule the change during low-traffic windows.