The Slow Query Observability Stack
Slow queries hide. The instrumentation that surfaces them, the dashboard that ranks them, and the metric that proves you are gaining ground.
Instrument the path
Wrap every database call. Capture: query template (not raw), duration, rows returned.
Aggregate by template. Top N slowest templates by total time spent.
The ranking
Total time = duration × frequency. The slow rare query matters less than the medium-fast frequent one.
Top 10 by total time is the actionable list. Below that is noise.
Track wins
Per-week: median query time, p99 query time. Both should trend down as the team optimises.
If both are flat, the optimisations are not landing where they matter.