Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Reads Django and PostgreSQL query plans from QuerySet.explain() or EXPLAIN ANALYZE to find scan, join, and row-count bottlenecks.
83% 91%+9 ptsof test cases passed
Passed 21 of 23 test cases with the skill, and 19 of 23 without it.
3 of 3 safety checks passed
35 agent runs
qs = Order.objects.filter(account_id=account_id, status="open").order_by("-created_at")
print(qs.explain())
print(qs.explain(analyze=True, verbose=True, buffers=True))
Use analyze=True only when executing the query is safe. buffers=True is PostgreSQL-specific and helps distinguish CPU work from page reads.
| Plan Cue | Meaning | Common Response |
|---|---|---|
Seq Scan on a large table with selective filter | No useful access path or planner rejected it | Consider matching index or rewrite filter |
Index Scan plus many rows removed by filter | Index finds too broad a set | Consider composite or partial index |
Bitmap Heap Scan | Many index matches batched before heap access | Often fine; check heap blocks and row counts |
Sort before Limit | Database sorted more rows than returned | Consider index matching filter plus ordering |
| Estimated rows far from actual rows | Planner statistics are stale or distribution is skewed | Run ANALYZE; consider extended stats or query rewrite |
| Nested loop with large inner repetitions | Join strategy may be expensive | Check indexes on join keys and row estimates |
| High heap fetches for index-only scan | Visibility map or selected columns prevent index-only benefit | Vacuum/analyze or revisit covering index expectations |
Keep a compact comparison:
Before: Seq Scan on orders, actual rows 2,850,000, sort on created_at, execution 1380 ms.
After: Index Scan using orders_open_created_idx, actual rows 50, no sort, execution 18 ms.
Why: partial index matches status=open and ordering, so PostgreSQL can stop at LIMIT.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.