What problem does it solve?
This Skill diagnoses slow SQL queries and EXPLAIN plans to identify index gaps, N+1 patterns, suboptimal joins, and full-table scans, then produces actionable, engine-specific recommendations and safe query rewrites that preserve correctness.
Core Features & Use Cases
- EXPLAIN interpretation: Translate scan types, join methods, cost hotspots, and estimated vs actual row mismatches into prioritized optimization actions.
- Anti-pattern detection: Find SELECT *, functions on indexed columns, leading-wildcard LIKE, implicit casts, OR across columns, correlated subqueries (N+1), and missing join conditions.
- Index and rewrite recommendations: Propose composite, partial, covering, or functional indexes and provide rewritten queries (e.g., converting correlated subqueries to JOINs) with clear explanations of impact and trade-offs.
- Engine-aware guidance: Tailor suggestions for PostgreSQL, MySQL, and SQLite, and flag when schema changes, denormalization, or materialized views are appropriate.
- Use cases: Speeding up slow API endpoints, resolving ORM N+1 issues in web apps, and optimizing analytical queries for reporting.
Quick Start
Use the sql-optimizer skill to analyze this SQL query and any provided EXPLAIN output, then return detected issues, recommended indexes, and an optimized query with explanations.