Finds why your code or query is slow — measured, ranked bottlenecks with the expected speedup of each fix, not folklore optimization.
Diagnose the performance of my {CODE / SQL QUERY / ENDPOINT}. Symptoms: {WHAT'S SLOW, HOW SLOW, AT WHAT SCALE — "fine with 100 rows, dies at 100k"}. Environment: {LANGUAGE/DB + anything relevant}.
Method — measure before optimizing:
1. INSTRUMENT FIRST: tell me exactly how to measure where time goes (the profiler command, the
EXPLAIN ANALYZE, the timing wrapper) so we're not guessing.
2. HYPOTHESES: the 3 most likely bottlenecks for this pattern and scale, ranked — with the
tell-tale signature each would show in the measurement.
3. Once identified (or for your top hypothesis now), THE FIX: corrected code/query, with expected order-of-improvement ("this turns O(n²) into O(n log n) — at your 100k rows, roughly 1000× fewer operations").
4. THE HIERARCHY check — in order, because each level dwarfs the next: algorithm choice → I/O and round-trips (N+1 queries, network calls in loops) → memory allocation patterns →
micro-optimizations. Refuse to micro-optimize if a higher level is unfixed.
5. GUARD: a simple benchmark/assertion to keep in place so this regression can't sneak back.
CODE/QUERY: {PASTE}