More screenshots

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIGitHub CopilotGitHub CopilotGemini CLIGemini CLI+20 more

    Sql Query Optimizer

    1

    Your production dashboard takes 12 seconds to load. The slow query log shows a SELECT that examines 2.

    Free

    5 installsSecurity scanned
    sql-query-optimizer

    sql-query-optimizer

    Example session with this skill installed

    "This query takes 12 seconds on our orders table (2.4M rows): sql SELECT id, title, status FROM orders WHERE EXTRACT(YEAR FROM created_at) = 2024 AND EXTRACT(MONTH FROM created_at) = 3 ORDER BY created_at DESC LIMIT 20; "

    • Read your context and instructions
    • Compiled the sql-query-optimizer

    "Diagnosis: Function-wrapped index column prevents index usage. EXTRACT() on created_at forces Seq Scan of 2.4M rows.

    Anti-pattern: SARGability violation — EXTRACT(YEAR FROM created_at) = 2024 makes the index on created_at unusable.

    Optimized query

    SELECT id, title, status FROM orders
    WHERE created_at >= '2024-03-01' AND created_at < '2024-04-01'
    ORDER BY created_at DESC LIMIT 20;
    

    Index recommendation

    CREATE INDEX idx_orders_created_status ON orders (created_at DESC, status);
    

    Expected improvement: Seq Scan (2.4M rows) → Index Scan (≈12K rows). Verify with:

    EXPLAIN (ANALYZE, BUFFERS) SELECT ...;
    

    Estimated time reduction: 12 seconds → <50ms."

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

    About this skill

    The Problem

    Your production dashboard takes 12 seconds to load. The slow query log shows a SELECT that examines 2.4 million rows to return 200. You added an index on created_at — it didn't help because the query wraps it in EXTRACT(YEAR FROM created_at), which makes the index useless. The query plan shows a Seq Scan, and your DBA is on vacation.

    What You Get

    • Anti-pattern detection — identifies function-on-indexed-column, SELECT *, accidental cross joins, NOT IN with nullable columns, LIKE '%prefix' searches, correlated subqueries, and OFFSET-based pagination on large result sets
    • EXPLAIN plan interpretation — reads PostgreSQL (Seq Scan → Index Scan analysis), MySQL (type: ALL, Using filesort), SQLite (SCAN TABLE), and SQL Server (Key Lookup, Table Scan) execution plans and translates them into actionable recommendations
    • Query rewriting engine — produces optimized queries with inline comments explaining each transformation, covering sargable predicates, JOIN restructuring, NOT EXISTS conversion, and keyset pagination
    • Index recommendation — generates exact CREATE INDEX statements with column order optimized for the identified access patterns, including composite indexes for multi-predicate queries
    • Cross-dialect awareness — handles dialect-specific optimizations (PostgreSQL window functions, MySQL implicit casts, SQLite query planner behavior, SQL Server key lookups)
    • Performance verification — generates EXPLAIN plan comparison scripts to validate that the optimized query actually performs better before deploying

    Why This Beats Prompting It Yourself

    You can paste a slow query and ask "optimize this." The agent will suggest an index or two. But it won't run EXPLAIN to verify the index actually helps, won't check if the query has three other anti-patterns you didn't notice, and won't catch the implicit type cast that makes your VARCHAR index invisible. This skill performs a systematic diagnosis — anti-pattern scan, EXPLAIN analysis, rewrite, verification — the same workflow a DBA follows, not the one-shot suggestion you get from a general-purpose agent.

    Example Session

    You: "This query takes 12 seconds on our orders table (2.4M rows):

    SELECT id, title, status FROM orders
    WHERE EXTRACT(YEAR FROM created_at) = 2024 AND EXTRACT(MONTH FROM created_at) = 3
    ORDER BY created_at DESC LIMIT 20;
    ```"
    
    Agent: "Diagnosis: Function-wrapped index column prevents index usage. EXTRACT() on created_at forces Seq Scan of 2.4M rows.
    
    Anti-pattern: SARGability violation — `EXTRACT(YEAR FROM created_at) = 2024` makes the index on created_at unusable.
    
    Optimized query:
    ```sql
    SELECT id, title, status FROM orders
    WHERE created_at >= '2024-03-01' AND created_at < '2024-04-01'
    ORDER BY created_at DESC LIMIT 20;
    

    Index recommendation:

    CREATE INDEX idx_orders_created_status ON orders (created_at DESC, status);
    

    Expected improvement: Seq Scan (2.4M rows) → Index Scan (≈12K rows). Verify with:

    EXPLAIN (ANALYZE, BUFFERS) SELECT ...;
    

    Estimated time reduction: 12 seconds → <50ms."

    Use Cases

    • Investigating slow queries flagged by production monitoring or slow query logs
    • Code review of SQL in PRs for performance anti-patterns before merge
    • Designing new queries that will run against large tables (100K+ rows)
    • Planning index strategy after analyzing actual query patterns
    • Migrating queries between database engines where dialect-specific behavior differs

    Known Limitations

    Optimization recommendations depend on accurate statistics — stale table statistics can make EXPLAIN plans misleading (run ANALYZE first). Index recommendations assume sufficient disk space and acceptable write overhead; every index slows INSERT/UPDATE/DELETE. The skill analyzes individual queries, not workload-wide query interaction effects. Always validate with EXPLAIN ANALYZE on production-representative data before deploying changes.

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 3

      Ask your agent to use it

      Restart the agent if it was already running. It picks the skill up automatically - no config needed.

    Skills folder by agent

    Click the path to copy it. Create the folder if it does not exist yet.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    5 installs

    Downloaded by developers to date

    Free forever

    No account required to browse

    Trust & safety

    Security scanned

    Verified clean 3 months ago

    • Free to download with an account

    Listed3 months ago
    Updated9 days ago

    What's inside

    Frequently Asked Questions