The query had failed again. You traced it to the schema change. The missing piece was obvious: a new column.
Adding a new column is simple in concept, but dangerous in production if done without care. Schema changes can lock tables, block writes, and create downtime. The goal is to evolve the database without breaking existing queries or degrading performance.
First, define the new column with clear intent. Know its data type, constraints, and default values. Avoid adding NOT NULL columns without defaults to large tables in one transaction—it can lock and rewrite the entire dataset.
Next, plan for index strategy. Do not add indexes blindly when creating the column. Measure usage once the application starts writing data. Index creation can be deferred or rolled out online, minimizing load.
Backfill safely. For large data sets, use batched updates to populate the new column. Monitor replication lag and error rates. Run these updates during off-peak hours to reduce contention.