Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    SQL Index Advisor for PostgreSQL and MySQL

    1

    Optimize PostgreSQL and MySQL performance with composite index design and redundancy auditing.

    $4

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    SQL Index Advisor for PostgreSQL and MySQL

    SQL Index Advisor for PostgreSQL and MySQL

    Example session with this skill installed

    Here are our slow queries and the table schema. Which indexes should I add, and which existing ones are redundant?

    • Read your context and instructions
    • Compiled the sql index advisor

    I ran the bundled script from the index-advisor 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

    Query tests/fixtures/index-advisor/queries.sql:2: SELECT id , total , created_at FROM orders WHERE customer_id = $1 AND status = 'paid' ORDER BY creat
      orders: extend orders_customer_id_idx -> (customer_id, status, created_at)
          - equality on customer_id, status first (any order among equality columns)
          - then ORDER BY created_at (with LIMIT: avoids sorting all rows)
          - covering variant adds id, total so the table is not visited
    Query tests/fixtures/index-advisor/queries.sql:7: SELECT id FROM customers WHERE email = $1
      customers: already served by customers_email_key
    Query tests/fixtures/index-advisor/queries.sql:10: SELECT oi . product_id , oi . quantity FROM orders o JOIN order_items oi ON oi . order_id = o . id W
      orders: already served by orders_pkey
      order_items: suggest (order_id)
          - join column order_id (looked up once per outer row)
          - covering variant adds product_id, quantity so the table is not visited
    Query tests/fixtures/index-advisor/queries.sql:15: SELECT c . country , count ( * ) FROM customers c WHERE c . created_at >= '2026-01-01' AND c . creat
      customers: suggest (country, created_at)
          - then GROUP BY country (rows arrive grouped; no hash/sort)
          - range on created_at last (columns after a range cannot be used for seeking)
    Query tests/fixtures/index-advisor/queries.sql:20: SELECT id FROM orders WHERE status = 'pending' ORDER BY created_at LIMIT 100
      orders: already served by orders_status_created_idx
    Query tests/fixtures/index-advisor/queries.sql:23: SELECT id FROM orders WHERE status = 'new' OR customer_id = 5
      orders: no index-friendly predicates
          note: top-level OR in WHERE: index each OR branch separately or rewrite as UNION ALL
    Query tests/fixtures/index-advisor/queries.sql:26: SELECT id , email FROM customers WHERE id IN ( SELECT customer_id FROM orders WHERE total > 1000 AND
      customers: already served by customers_pkey
      orders: extend orders_status_idx -> (status, total)
          - equality on status first (any order among equality columns)
          - range on total last (columns after a range cannot be used for seeking)
          - covering variant adds customer_id so the table is not visited
    
    Proposed indexes (4):
      -- replaces orders_customer_id_idx (drop it after the new index is valid)
      CREATE INDEX CONCURRENTLY orders_customer_id_status_created_at_idx ON orders (customer_id, status, created_at);   -- serves tests/fixtures/index-advisor/queries.sql:2
      -- covering variant: CREATE INDEX CONCURRENTLY orders_customer_id_status_created_at_idx ON orders (customer_id, status, created_at) INCLUDE (id, total);
      CREATE INDEX CONCURRENTLY order_items_order_id_idx ON order_items (order_id);   -- serves tests/fixtures/index-advisor/queries.sql:10
      -- covering variant: CREATE INDEX CONCURRENTLY order_items_order_id_idx ON order_items (order_id) INCLUDE (product_id, quantity);
      CREATE INDEX CONCURRENTLY customers_country_created_at_idx ON customers (country, created_at);   -- serves tests/fixtures/index-advisor/queries.sql:15
      -- replaces orders_status_idx (drop it after the new index is valid)
      CREATE INDEX CONCURRENTLY orders_status_total_idx ON orders (status, total);   -- serves tests/fixtures/index-advisor/queries.sql:26
      -- covering variant: CREATE INDEX CONCURRENTLY orders_status_total_idx ON orders (status, total) INCLUDE (customer_id);
    Redundant indexes (cost on every write, check usage before dropping):
      duplicate: orders_status_idx (status) duplicates orders_status_dup_idx
      redundant: orders_status_dup_idx (status) is a left prefix of orders_status_created_idx (status, created_at)
    Verify every change with EXPLAIN before and after; build on a replica or staging copy first.
    

    Next steps

    1. Create the suggested indexes on a staging copy and compare EXPLAIN before and after.
    2. Drop redundant indexes only after checking they are unused in production stats.
    3. Re-run the advisor whenever query patterns change.

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

    About this skill

    Database performance often degrades because of missing indexes or redundant ones that slow down writes. This skill analyzes SQL queries against your schema to design the most efficient B-tree index set without manual trial and error.

    What it does

    • Design composite indexes by applying the equality, sort, range rule for optimal query performance.
    • Identify covering indexes using INCLUDE or appended columns to eliminate heap fetches for hot paths.
    • Detect redundant indexes by finding duplicate or left-prefix overlaps that waste storage and IO.
    • Consolidate recommendations by proposing a single wider index that serves multiple queries instead of many narrow ones.
    • Generate safe DDL producing CONCURRENTLY or INPLACE statements that avoid blocking production writes.

    How it works

    1. Provide inputs including your real SQL queries and a schema-only dump of the target tables.
    2. Execute analysis using the advisor script with optional dialect flags for PostgreSQL or MySQL.
    3. Review recommendations including the specific reasoning for column ordering and whether to extend an existing index.
    4. Verify usage by running provided statistical queries on your database to confirm an index is truly unused before dropping.

    Frameworks & tools

    This tool uses a Python-based analyzer that parses standard SQL. It supports PostgreSQL and MySQL/MariaDB dialects.

    Why this beats prompting it yourself

    Generic LLM prompts often ignore index cardinality or the specific ordering rules required for composite indexes to work with ORDER BY. This skill follows a strict engineering workflow to ensure the resulting DDL is actually usable and safe for high-traffic tables.

    Use cases

    • Optimizing slow queries identified in logs or APM tools.
    • Cleaning up index bloat after years of uncoordinated schema migrations.
    • Designing schema for a new feature to ensure join columns are correctly indexed.
    • Reviewing pull requests to ensure new indexes follow best practices.

    Known limitations

    Does not support GIN, GiST, or FULLTEXT indexes. It cannot connect to your database directly and requires manual schema and query exports.


    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.

    Supports only B-tree indexes. No support for GIN, GiST, or spatial types. Requires manual export of schema and queries as .sql files. Does not connect to live databases.

    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

    The Index Advisor designs high-performance composite indexes and identifies redundant ones that slow down your database, helping you resolve slow query issues and reduce storage bloat without manual trial and error.

    It is fully compatible with PostgreSQL and MySQL (including MariaDB) dialects; you simply provide your schema dump and query logs to the agent for analysis.

    No direct connection is required; for security and privacy, the skill works by analyzing schema exports and SQL query text that you provide manually.

    You receive the full Python-based analyzer logic and the specialized agent instructions needed to generate optimal, production-ready DDL statements.

    The skill provides DDL generated with 'CONCURRENTLY' for PostgreSQL or 'ALGORITHM=INPLACE' for MySQL to ensure that applying the new indexes does not lock your tables or interrupt production traffic.

    While it excels at B-tree optimization, it currently does not support specialized index types like GIN, GiST, or FULLTEXT.

    New in Data & Databases