Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    SQL EXPLAIN Plan Analyzer for PostgreSQL and MySQL

    1

    Analyze PostgreSQL and MySQL EXPLAIN plans to find hotspots, misestimates, and disk spills with concrete fixes.

    $6

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    SQL EXPLAIN Plan Analyzer for PostgreSQL and MySQL

    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

    1. Add the suggested index on the filter column and ANALYZE the table.
    2. Raise work_mem for this query only if the sort still spills.
    3. 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

    1. Input collection starts by requesting EXPLAIN (ANALYZE, BUFFERS) for PostgreSQL or EXPLAIN ANALYZE for MySQL.
    2. Automated parsing runs the provided plan through a Python script to strip database-specific decorations and calculate self-time metrics.
    3. Finding prioritization generates a list of bottlenecks ordered by impact (e.g., Seq Scan, Sort, Hash Join).
    4. Correction proposal provides a single concrete change, such as a specific index definition or a SET LOCAL work_mem command.

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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+

    Permissions

    Terminal / Shell
    Read Files
    Listedtoday

    What's inside

    Frequently Asked Questions

    This skill calculates 'self time' for each node, which isolates the exact source of a delay rather than just flagging the total execution time of a branch. It also detects nuanced issues like memory spills to disk and implicit type casts that standard LLM prompts often overlook.

    The skill supports PostgreSQL (using `ANALYZE` and `BUFFERS` for best results) and MySQL/MariaDB (JSON, Tree, and Analyze formats). It can handle both raw console output and `auto_explain` logs from production environments.

    No direct connection is required. To maintain security, you simply provide the text or JSON output of your EXPLAIN plan, and the skill parses the data locally within your AI agent's environment.

    You receive the specialized AI agent skill, the Python-based parsing engine for precise metric calculation, and a guide on how to generate the most useful plan outputs for analysis.

    This skill is designed for any AI agent capable of running Python 3.8+ scripts. It is pre-configured to work with popular frameworks that support tool-calling or code execution environments.

    The analysis focuses on the top-impact bottlenecks, offering one high-priority fix at a time—such as a specific index definition, a statistics update command, or a memory parameter adjustment like `work_mem`.

    New in Data & Databases