0172-sql-optimization-patterns
CommunityOptimize SQL queries with indexing and EXPLAIN.
System Documentation
What problem does it solve?
This Skill helps you dramatically improve slow database performance by diagnosing query execution behavior and applying proven indexing and query-shaping patterns.
Core Features & Use Cases
- Query Plan Diagnosis with EXPLAIN: Learn how to interpret Seq Scan vs Index/Index Only Scan, join strategies, and the difference between estimated costs and actual execution times (EXPLAIN vs EXPLAIN ANALYZE).
- Indexing Strategies That Match Your Queries: Choose B-Tree, composite, partial, expression, covering (INCLUDE), GIN, GiST, and BRIN indexes to eliminate full scans and support efficient filtering, joins, and search.
- Optimization Patterns for Common Bottlenecks: Fix N+1 query problems, replace inefficient OFFSET pagination with cursor-based pagination, speed up COUNT/GROUP BY, and rewrite correlated subqueries and aggregations.
Use case example: When a slow endpoint shows long response times, you analyze the failing query with EXPLAIN ANALYZE, identify missing or mismatched indexes, then apply a pattern (e.g., cursor pagination or a JOIN-based aggregation) to reduce execution time and database load.
Quick Start
Ask the AI to review your slow SQL statement and the relevant EXPLAIN ANALYZE output, then recommend specific index definitions and query rewrites using the patterns from this Skill.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: 0172-sql-optimization-patterns Download link: https://github.com/MrJmpl3/codex_____data_____configuration/archive/main.zip#0172-sql-optimization-patterns Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.