- Home
- Skills
- Data & Databases
- SQL EXPLAIN Plan Analyzer for PostgreSQL and MySQL
Works with the AI Agents you already use
SQL EXPLAIN Plan Analyzer for PostgreSQL and MySQL
Analyze PostgreSQL and MySQL EXPLAIN plans to find hotspots, misestimates, and disk spills with concrete fixes.
$6
SQL EXPLAIN Plan Analyzer for PostgreSQL and MySQL
Example session with this skill installed
This PostgreSQL query takes almost a second. Here is EXPLAIN (ANALYZE, FORMAT JSON). Why is it slow and how do I fix it?
- Read your context and instructions
- Compiled the sql explain plan
I ran the bundled script from the explain-plan-analysis skill and reviewed its findings.
Demo data: this is the real, unedited output of the skill's script on the test fixture that ships with its source repo.
Script output
postgresql plan (ANALYZE, execution 870.3 ms, planning 0.9 ms): 4 medium, 2 low
Hotspots:
520.70 ms (59.8%) Seq Scan on orders rows=48210 loops=1
220.70 ms (25.4%) Sort rows=48210 loops=1
59.40 ms (6.8%) Hash Join rows=48210 loops=1
30.50 ms (3.5%) Seq Scan on customers rows=50000 loops=1
29.60 ms (3.4%) Hash rows=50000 loops=1
MEDIUM sort_spill: Sort spilled to disk (external merge, 9120 kB)
fix: index the ORDER BY columns, add LIMIT, or raise work_mem for this query (SET LOCAL work_mem = '64MB')
MEDIUM seq_scan: Seq Scan on orders reads 1,000,000 rows, filter keeps 48,210
fix: selective filter - index candidate: ((status)::text = 'pending'::text)
MEDIUM hash_spill: Hash used 4 batches (hash table spilled to disk)
fix: raise work_mem / hash_mem_multiplier for this query or reduce the hashed input
MEDIUM misestimate: Seq Scan on orders: estimated 1,200 rows, actual 48,210 (underestimate x40)
fix: ANALYZE the table; raise the column statistics target; for correlated columns CREATE STATISTICS (dependencies, ndistinct)
LOW seq_scan: Seq Scan on customers reads 50,000 rows
fix: fine for small tables or when most rows are needed; otherwise index the filter columns
LOW jit_overhead: JIT took 132 ms of 870 ms
fix: for short OLTP queries set jit = off (or raise jit_above_cost)
Next steps
- Add the suggested index on the filter column and ANALYZE the table.
- Raise work_mem for this query only if the sort still spills.
- Re-run EXPLAIN ANALYZE and compare execution time.
Connects securely to your tools. The creator never sees your data.
About this skill
Slow SQL queries stall production and drain resources. This skill parses PostgreSQL and MySQL EXPLAIN outputs to identify exactly where execution time is lost, why the optimizer chose a specific path, and how to fix it.
What it does
- Hotspot identification calculates "self time" per node to isolate the biggest bottlenecks.
- Misestimate detection compares planner estimates against actual row counts to find stale statistics or missing histograms.
- Scan analysis flags sequential scans with selective filters and scans repeated inside nested loops.
- Resource monitoring detects sorts or hashes spilling to disk and high JIT overhead.
- Root cause mapping identifies implicit type casts, leading wildcards, and low-selectivity indexes.
How it works
- Input collection starts by requesting
EXPLAIN (ANALYZE, BUFFERS)for PostgreSQL orEXPLAIN ANALYZEfor MySQL. - Automated parsing runs the provided plan through a Python script to strip database-specific decorations and calculate self-time metrics.
- Finding prioritization generates a list of bottlenecks ordered by impact (e.g., Seq Scan, Sort, Hash Join).
- Correction proposal provides a single concrete change, such as a specific index definition or a
SET LOCAL work_memcommand.
Frameworks & tools
Built for PostgreSQL (standard and auto_explain logs) and MySQL/MariaDB (JSON, Tree, and Analyze formats). The underlying analyzer is a Python-based CLI tool.
Why this beats prompting it yourself
Generic prompts often miss the difference between a node's total time and its self time, leading you to optimize the wrong part of the tree. This skill uses precise calculations to isolate the exact node responsible for the delay rather than its children.
Use cases
- Debugging why an existing index is being ignored by the query planner.
- Reducing disk I/O by resolving memory spills in large sorts and hashes.
- Fixing bad join orders caused by row count misestimates on correlated columns.
- Comparing before/after execution plans to verify the impact of a new index.
Known limitations
Does not connect to the database directly. Requires the user to provide text or JSON plan output. Standard Python 3.8+ environment required for the analysis script.
Open source: saizul/sql-database-skills on GitHub (MIT licence, by Saizul Amin).
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Requires manual plan export from DB. Analyzes static plans; does not execute SQL. Python 3.8+ required for scripts.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed today
- Software
Python 3.8+