Index Advisor
Analyze query patterns and recommend optimal database indexes
- Type
- Slash Command
- Repository
- jeremylongshore/tons-of-skills-marketplace
- GitHub stars
- 2.8k
- License
- MIT
- Repo last updated
- Sep 27, 2026
What Index Advisor is
Index Advisor is a slash command published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”
A slash command is a reusable prompt saved as a markdown file and run by typing its name after a slash. In Claude Code, custom commands have been merged into skills: a file in .claude/commands/ and a skill folder in .claude/skills/ both create the same kind of command, and existing command files keep working.
Index Advisor gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.
How to install Index Advisor
Claude Code
- Download index-advisor.md from the repository.
- Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md.
- Run it by typing / followed by its name.
Claude Cowork
- Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
- In Customize → Skills, click +, then upload the ZIP.
- Run it from any task with / and the skill name.
New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.
Inside the source file
An excerpt from plugins/database/database-index-advisor/commands/index-advisor.md, shared under the repository's MIT license. Read the full file on GitHub.
Analyze query workloads, identify missing indexes, detect unused indexes, and recommend optimal indexing strategies with automated index impact analysis and maintenance scheduling for production databases.
When to Use This Command
Use /index-advisor when you need to:
- Optimize slow queries with proper indexing strategies
- Analyze database workload for missing index opportunities
- Identify and remove unused indexes consuming storage and write performance
- Design composite indexes for multi-column query patterns
- Implement covering indexes to eliminate table lookups
- Monitor index bloat and schedule maintenance (REINDEX, VACUUM)
DON'T use this when:
- Database is small (<1GB) with minimal query load
- All queries are simple primary key lookups
- You're looking for application-level query issues (use query optimizer instead)
- Database doesn't support custom indexes (some managed databases)
Design Decisions
This command implements workload-based index analysis because:
- Real query patterns reveal actual index opportunities
- EXPLAIN ANALYZE provides accurate index impact estimates
- Unused index detection prevents unnecessary write overhead
- Composite index recommendations reduce total index count
- Covering indexes eliminate expensive table lookups (3-10x speedup)
Alternative considered: Static schema analysis
- Only analyzes table structure, not query patterns
- Can't estimate real-world performance impact
- May recommend indexes that won't be used
- Recommended only for initial schema design
Alternative considered: Manual EXPLAIN analysis
- Requires deep SQL expertise for every query
- Time-consuming and error-prone
- No systematic unused index detection
- Recommended only for ad-hoc optimization
Prerequisites
Before running this command:
- Access to database query logs or slow query log
- Permission to run EXPLAIN ANALYZE on queries
- Monitoring of database storage and I/O metrics
- Understanding of application query patterns
- Maintenance window for index creation (for large tables)
Implementation Process
Step 1: Collect Query Workload Data
Capture real production queries from logs or pg_stat_statements.
Step 2: Analyze Query Execution Plans
Run EXPLAIN ANALYZE to identify sequential scans and suboptimal query plans.
Step 3: Generate Index Recommendations
Identify missing indexes, composite index opportunities, and covering indexes.
Step 4: Simulate Index Impact
Estimate query performance improvements with hypothetical indexes.
Step 5: Implement and Monitor Indexes
Create recommended indexes and track query performance improvements.
Output Format
The command generates:
- analysis/missing_indexes.sql - CREATE INDEX statements for missing indexes
- analysis/unused_indexes.sql - DROP INDEX statements for unused indexes
- reports/index_impact_report.html - Visual impact analysis with before/after metrics
- monitoring/index_health.sql - Queries to monitor index bloat and usage
- maintenance/reindex_schedule.sh - Automated index maintenance script
Code Examples
Example 1: PostgreSQL Index Advisor with pg_stat_statements
-- Enable pg_stat_statements extension for query tracking
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
-- Configure extended statistics
ALTER SYSTEM SET pg_stat_statements.track = 'all';
ALTER SYSTEM SET pg_stat_statements.max = 10000;
SELECT pg_reload_conf();
-- View most expensive queries without proper indexes
CREATE OR REPLACE VIEW slow_queries_needing_indexes AS
SELECT
queryid,
LEFT(query, 100) AS query_snippet,
calls,
total_exec_time,
mean_exec_time,
max_exec_time,
stddev_exec_time,
…# scripts/index_advisor.py - Comprehensive Index Analysis Tool
import psycopg2
from psycopg2.extras import DictCursor
import re
import logging
from typing import List, Dict, Tuple, Optional
from dataclasses import dataclass, asdict
from collections import defaultdict
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@dataclass
class IndexRecommendation:
"""Represents an index recommendation with impact analysis."""
table_name: str
recommended_index: str
reason: str
…Example 2: MySQL Index Advisor with Performance Schema
-- Enable performance schema for query analysis
UPDATE performance_schema.setup_instruments
SET ENABLED = 'YES', TIMED = 'YES'
WHERE NAME LIKE 'statement/%';
UPDATE performance_schema.setup_consumers
SET ENABLED = 'YES'
WHERE NAME LIKE '%statements%';
-- Identify slow queries needing indexes
CREATE OR REPLACE VIEW slow_queries_analysis AS
SELECT
DIGEST_TEXT AS query,
COUNT_STAR AS executions,
ROUND(AVG_TIMER_WAIT / 1000000000, 2) AS avg_time_ms,
ROUND(MAX_TIMER_WAIT / 1000000000, 2) AS max_time_ms,
ROUND(SUM_TIMER_WAIT / 1000000000, 2) AS total_time_ms,
SUM_ROWS_EXAMINED AS total_rows_examined,
… Before you install
- Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
- Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
- Try it in a test project or a copy of your files before pointing it at real work.
- Pin the version you tested, and review changes before updating.
- Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.
FAQ
What is Index Advisor?
Index Advisor is a slash command for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Analyze query patterns and recommend optimal database indexes
How do I install Index Advisor in Claude Code?
Download index-advisor.md from the repository. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md. Run it by typing / followed by its name.
Can I use Index Advisor in Claude Cowork?
Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it. In Customize → Skills, click +, then upload the ZIP. Run it from any task with / and the skill name.
Is Index Advisor safe to install?
It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.
Similar resources
- Zero Tech Debt Rebuild a feature as if the correct product architecture existed from day one. Removes compatibility cruft, dead abstractions, and historical compromises instead of preserving them. Methodology-only — no destructive actions without operator approval. Plugin · jeremylongshore/tons-of-skills-marketplace
- Yt Scraper Orchestrates YouTube data extraction via Apify actors — channel metadata, video details, search results — polling until complete and saving all datasets to disk. Use when collecting raw YouTube data for strategy analysis. Trigger with "scrape youtube channels", "fetch youtube data". Subagent · jeremylongshore/tons-of-skills-marketplace
- 003 Jeremy Vertex Ai Media Master Comprehensive Google Vertex AI multimodal mastery for Jeremy - video processing (6+ hours), audio generation, image creation with Gemini 2.0/2.5 and Imagen 4. Marketing campaign automation, content generation, and media asset production. Plugin · jeremylongshore/tons-of-skills-marketplace
- 002 Jeremy Yaml Master Agent Intelligent YAML validation, generation, and transformation agent with schema inference, linting, and format conversion capabilities Plugin · jeremylongshore/tons-of-skills-marketplace
- Init Genkit Project Initialize a new Firebase Genkit project with best practices, proper Slash Command · jeremylongshore/tons-of-skills-marketplace
- Incident P0 Disk Full Emergency response for SOP-203 P0 - Disk Space Emergency Slash Command · jeremylongshore/tons-of-skills-marketplace
- Itinerary AI-powered itinerary generator with personalized day-by-day travel plans Slash Command · jeremylongshore/tons-of-skills-marketplace
- Incident P0 Database Down Emergency response procedure for SOP-201 P0 - Database Down (Critical) Slash Command · jeremylongshore/tons-of-skills-marketplace