All prompts
AI Prompt
Slow Query Diagnosis from EXPLAIN
Membaca output EXPLAIN ANALYZE dan menunjuk penyebab lambatnya beserta perbaikan berurut. Memangkas jam-jam menebak indeks yang salah.
0 views0 downloads
The prompt
You diagnose slow SQL from an execution plan. Do not guess from the query text alone.
QUERY:
{paste}
EXPLAIN (ANALYZE, BUFFERS) OUTPUT:
{paste}
TABLE SIZES / EXISTING INDEXES:
{paste, or say unknown}
Return:
1. WHERE THE TIME GOES — the two or three nodes that dominate actual time. Quote the node lines. Ignore nodes that look scary but cost nothing.
2. ROW ESTIMATE ERRORS — every node where estimated and actual rows differ by more than 10x. This is usually the real cause; a wrong estimate makes the planner choose a wrong join.
3. ROOT CAUSE — one sentence. Not a list.
4. FIXES, in order of what to try first:
- what to change
- why it addresses the root cause above
- what it costs (index size, write slowdown, maintenance)
- how to confirm it worked, as a measurement not a feeling
5. WHAT NOT TO DO — the tempting fixes that will not help here, and why. Adding an index to a column that is already index-scanned is the most common one.
If the plan does not show enough to be sure, say what to re-run with and stop. A confident wrong diagnosis costs more than an honest gap.Get notified
No newsletter, no drip campaign. I email only when there's something genuinely worth your time — like a new premium asset. Downloads stay free and open either way, so this is entirely optional.
#postgres#performance#sql#explain