1

    Sql Query Optimizer

    Expert-level SQL tuning and performance auditing for PostgreSQL, MySQL, SQLite, and SQL Server.

    Updated Jun 2026
    Security scanned
    Cursor

    $14.99

    · or 75 credits

    30-day refund guarantee

    Secure checkout via Stripe

    Included in download

    • Convert slow OFFSET-based pagination to high-performance keyset pagination.
    • Eliminate N+1 query patterns in application code through efficient JOINs.
    • terminal automation included
    • Ready for Cursor
    • Instant install

    Sample input

    This analytical query on our 500k row orders table is taking 30 seconds. Can you optimize it and suggest any missing indexes? SELECT * FROM orders WHERE EXTRACT(YEAR FROM created_at) = 2024;

    Sample output

    I've rewritten the query to use a sargable range scan: `SELECT id, customer_id, total FROM orders WHERE created_at >= '2024-01-01' AND created_at < '2025-01-01';` Recommendation: Create an index on `created_at`. This changes a full Table Scan (500k rows) to an Index Range Scan (~12k rows).

    About This Skill

    What it does

    This skill transforms your AI agent into a senior database performance engineer. It provides a systematic methodology for diagnosing slow SQL queries, interpreting complex execution plans, and rewriting code for maximum efficiency across PostgreSQL, MySQL, SQLite, and SQL Server.

    Why use this skill

    Standard LLMs often suggest generic SQL adjustments that might not actually trigger index usage or could even degrade write performance. This skill implements a developer-centric workflow: it demands EXPLAIN plans, identifies specific anti-patterns like non-sargable predicates and N+1 loops, and provides concrete before/after benchmarks. It ensures your agent understands dialect-specific nuances, such as how MySQL handles implicit type casts versus PostgreSQL's CTE materialization strategies.

    Key Features

    • Execution Plan Analysis: Deep interpretation of EXPLAIN ANALYZE and SCAN TABLE outputs.
    • Index Strategy: Recommendations for composite and covering indexes based on read-to-write ratios.
    • Query Refactoring: Converting slow correlated subqueries into efficient joins and implementing keyset pagination.
    • Anti-Pattern Detection: Automatic flagging of 'SELECT *', wildcard prefixes, and improper NULL handling.

    The Output

    The agent delivers a structured performance report including the optimized SQL, the specific reasoning for each change, detailed index recommendations, and an estimated performance delta (e.g., Seq Scan to Index Scan transition).

    Use Cases

    • Reduce query latency by identifying and fixing non-sargable WHERE clauses.
    • Convert slow OFFSET-based pagination to high-performance keyset pagination.
    • Eliminate N+1 query patterns in application code through efficient JOINs.
    • Interpret EXPLAIN plans to fix full table scans in production environments.

    Reviews

    No reviews yet - be the first to share your experience.

    Only users who have downloaded or purchased this skill can leave a review.

    Security Scanned

    Passed automated security review

    Permissions

    Terminal / Shell

    Allowed Hosts

    www.postgresql.org
    dev.mysql.com
    www.sqlite.org
    learn.microsoft.com
    use-the-index-luke.com
    www.brentozar.com

    File Scopes

    sql-query-optimizer/**

    Compatible with SKILL.md-compatible agents including Claude Code, Cursor, and Aider.

    Frequently Asked Questions