Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Postgres Query Optimizer: Find & Prove the Fix

    2

    Runs EXPLAIN ANALYZE safely, pinpoints exactly why your Postgres query is slow, and tests every fix in a rolled-back transaction. Verified 375–2,347× speedups.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Postgres Query Optimizer: Find & Prove the Fix

    Postgres Query Optimizer: Find & Prove the Fix

    Example session with this skill installed

    On the connected staging database, optimize SELECT * FROM orders WHERE customer_id = 842 AND status = 'pending'. You may test fixes and roll them back. Give me the SQL worth applying.

    • Read your context and instructions
    • Compiled the postgres query optimizer

    The query's median execution time fell from

    240 ms to 36 ms, an

    85% reduction, with a composite index in staging.
    Test changes were rolled back. No index was kept.

    Findings and tested fixes

    The main bottleneck was a full scan of orders, discarding 1,199,976 rows to return 24. No existing index covered both filter columns.

    TestMedian timeResult
    Original query240 msBaseline
    Index on customer_id and status36 msVerified improvement
    Statistics refresh alone236 msNo meaningful improvement

    The indexed plan used a bitmap index scan followed by a bitmap heap scan instead of reading the entire table.

    SQL worth applying

    For production, build the index concurrently to avoid blocking normal writes during the build. Run this outside a transaction block:

    CREATE INDEX CONCURRENTLY idx_orders_customer_status
    ON orders (customer_id, status);
    
    ANALYZE orders;
    

    The index consumes disk space and adds work to inserts and updates. This test did not measure that write overhead. Staging results may differ from production.

    Detailed plan timings and test comparisons are in pgopt-output/report.md.

    Next steps

    • Confirm staging data volume is representative of production.
    • Apply the index during an appropriate deployment window.
    • Recheck query timing and write performance after deployment.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    A slow database query can hold up an entire page or endpoint. Find where PostgreSQL spends its time, get specific fixes, and test whether they actually help before keeping them.

    What it does

    • Explains the bottleneck: Reads the query execution plan to identify expensive scans, joins, sorts, and other slow steps.
    • Suggests targeted fixes: Recommends relevant indexes, statistics updates, or memory settings rather than guessing from SQL alone.
    • Tests improvements: With database access and permission, compares timings and rolls back the test changes.
    • Reports what failed: Shows tested fixes that did not help, alongside the exact SQL for useful changes.

    How it works

    1. Share a slow query with database access, or paste a PostgreSQL execution plan.
    2. Get a breakdown of the costly steps and suggested fixes.
    3. Approve live testing if you want measured comparisons.
    4. Review the report and choose which changes to apply.

    Works with

    PostgreSQL, including Supabase, Neon, Amazon RDS, and Cloud SQL. Running the tool requires Python 3 and the PostgreSQL psql client. Offline analysis works from a JSON execution plan.

    Why use this skill

    Avoid spending time adding indexes that do not address the bottleneck. Measured comparisons help you separate useful changes from ones that only sound promising.

    Use cases

    • Diagnose a slow customer dashboard query.
    • Check whether a proposed index improves an endpoint.
    • Review a query plan without sharing database access.

    Known limitations

    Handles one query at a time. Test timings depend on the environment. Index tests can block writes, so production testing needs care.

    Optimizes one query at a time. Does not model index write overhead or auto-verify query rewrites. Timings depend on test data; live index tests can block writes.

    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 any payment.

    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 1 month ago

    Permissions

    Terminal / Shell
    Environment Variables
    Listed1 month ago

    What's inside

    Frequently Asked Questions

    The skill analyzes PostgreSQL execution plans to identify specific bottlenecks like sequential scans or inefficient joins, then suggests and tests optimizations—such as new indexes or rewritten SQL—to verify actual performance gains.

    Yes, you can paste a JSON execution plan for offline analysis without providing direct database access. However, live features like automated performance testing and rollback require a connection to your PostgreSQL instance.

    It is compatible with any PostgreSQL environment, including managed services like Supabase, Neon, AWS RDS, and Google Cloud SQL, provided your environment has Python 3 and the psql client installed.

    When testing index changes, the skill can briefly lock tables, which may impact write operations. We recommend running automated tests in a staging environment or during low-traffic windows to ensure production stability.

    You receive the full AI agent skill, including the logic for plan analysis, a suite of optimization strategies, and the automated testing/rollback scripts for measured verification.

    New in Data & Databases