Find the slow thing before optimising
This is slow: {{describe symptom, e.g. endpoint takes 4s at p95}}. Here's the code and what I know: {{paste code, query plans, timings, data volumes}}.
Don't optimise yet. First:
1. Build the cost model — for one request, list every I/O operation, its count, and its likely latency. Show where the time probably goes as a budget that sums to the observed total.
2. Rank hypotheses by expected share of the time, and for each say what measurement would confirm it. Name the exact thing to instrument.
3. Only then: for the top two hypotheses, give the fix, the expected improvement with reasoning, and the risk.
4. Identify anything that gets faster but breaks correctness under concurrency or at scale.
5. Tell me which "optimisations" here would be premature and why.
6. Define the benchmark I should run before and after, with the exact numbers to record.
If the data volumes I gave you don't explain the latency, say so and tell me what to measure next.
How to use it
The cost model in step 1 usually finds an N+1 query or a missing index before you write any code.
Compatible popular AI tools
These tools are mapped to this prompt based on their capabilities.
People who liked this prompt
15 community likes
No likes yet. Be the first.