sql-optimization

Analyze SQL query plans and implement targeted indexes to fix performance bottlenecks.

Updated Apr 19, 2026
One-click install
npx skills add https://github.com/saranskumar/anti-slop --skill sql-optimization-saranskumar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization
Source: https://github.com/saranskumar/anti-slop/tree/main/skills/sql-optimization
Command: npx skills add https://github.com/saranskumar/anti-slop --skill sql-optimization-saranskumar

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Slow SQL queries hurt performance and escalate maintenance costs; this skill provides a disciplined method to identify bottlenecks, design effective indexes, and rewrite queries for speed.

Core Features & Use Cases

  • EXPLAIN ANALYZE-driven bottleneck discovery and validation
  • Index strategies: composite, partial, and covering indexes, plus expression-based indexes
  • N+1 elimination and query rewrites to use joins and batch fetching
  • Use Case: optimizing a reporting query that aggregates orders per user or reduces a user-facing latency by rewriting subqueries into joins

Quick Start

Run EXPLAIN ANALYZE on the slow query, then implement a targeted composite index based on the report's WHERE and JOIN conditions.

Frequently Asked Questions about sql-optimization

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

FAQPage Schema
How do I speed up slow SQL queries using EXPLAIN ANALYZE?

To speed up slow SQL queries, use EXPLAIN ANALYZE to measure query plans and identify performance bottlenecks. This skill provides a disciplined method to execute query plans, discover exact bottleneck locations, and validate improvements using controlled benchmarks.

When do I need to create composite or partial indexes for database design?

You need composite or partial indexes when your queries filter or join on multiple columns and standard indexing falls short. This skill designs effective index strategies, including covering and expression-based indexes, based on precise WHERE and JOIN conditions.

What is the best way to eliminate N+1 query patterns in SQL?

The best way to eliminate N+1 query patterns is by rewriting queries to use joins and batch fetching. This skill targets N+1 elimination and query rewrites to optimize data retrieval, reducing user-facing latency in complex joins.

Can I optimize a reporting query that aggregates orders per user in production?

Yes, you can optimize reporting queries that aggregate orders per user across development and production environments. This skill applies bottleneck discovery and targeted indexing to reduce slow reporting query execution times.

Why does my SQL query tuning not improve performance despite adding indexes?

SQL query tuning may fail if indexes do not align with the query plan bottlenecks discovered. This skill implements precise indexing based on EXPLAIN ANALYZE measurements and validates improvements with controlled benchmarks.