optimizing-sql-queries

Analyze SQL queries and generate index recommendations and query rewrites.

2.6k|379|Updated Oct 10, 2025
One-click install
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus --skill optimizing-sql-queries
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: optimizing-sql-queries
Source: https://github.com/jeremylongshore/claude-code-plugins-plus/tree/main/plugins/database/sql-query-optimizer/skills/sql-query-optimizer
Command: npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus --skill optimizing-sql-queries

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This skill empowers Claude to analyze SQL queries, identify performance bottlenecks, and suggest optimizations such as index creation or query rewriting. It leverages the sql-query-optimizer plugin to provide actionable recommendations for improving database performance and efficiency.

Core Features & Use Cases

  • Query Analysis: Analyze SQL structure and execution plans to pinpoint inefficiencies.
  • Index Recommendations: Suggest optimal indexes to speed up slow queries.
  • Query Rewrites: Propose alternative, more efficient query formulations.
  • Use Case: Optimize a slow SELECT query by identifying missing indexes and suggesting a more efficient query structure.

Quick Start

User request: "Optimize this SQL query: SELECT * FROM orders WHERE customer_id = 123 AND order_date < '2023-01-01';"

The skill will:

  1. Analyze the provided SQL query.
  2. Suggest creating an index on customer_id and order_date columns to improve query performance.

Frequently Asked Questions about optimizing-sql-queries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize slow SQL queries?

Query optimization involves analyzing SQL structure and execution plans to identify inefficiencies, then applying fixes like index creation or query rewriting. This skill analyzes your queries, recommends missing indexes, and suggests more efficient query formulations to improve performance.

What does an EXPLAIN plan show and how do I use it?

An EXPLAIN plan reveals how a database executes your query, exposing bottlenecks like full table scans or missing indexes. Provide your query and EXPLAIN output to this skill for detailed analysis and optimization recommendations.

How do I identify which indexes are missing from my database?

Missing indexes appear in slow query execution plans as full table scans or inefficient joins. This skill analyzes your SQL queries and EXPLAIN plans to pinpoint which indexes on specific columns would accelerate performance.

Can I rewrite a query to run faster without changing the results?

Yes, query rewriting restructures SQL to produce identical results using more efficient logic—eliminating redundant joins, reordering conditions, or using better aggregation approaches. This skill suggests alternative formulations based on your query structure.

What SQL queries benefit most from optimization?

Queries with high execution time, large result sets, complex joins, or repeated full table scans benefit most from optimization. This skill targets slow SELECT queries, missing index scenarios, and queries across relational databases.