sql-optimization-patterns

Optimizes slow SQL queries using indexing strategies and EXPLAIN plan analysis.

Updated Feb 13, 2026
One-click install
npx skills add https://github.com/mwathiben/PropManager --skill sql-optimization-patterns-mwathiben
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/mwathiben/PropManager/tree/main/.claude/skills/sql-optimization-patterns
Command: npx skills add https://github.com/mwathiben/PropManager --skill sql-optimization-patterns-mwathiben

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Slow SQL queries hamper application performance, wasting compute, increasing latency, and driving costs. This Skill provides a structured approach to diagnose and fix bottlenecks through pattern-driven optimization, indexing strategies, and query plan analysis.

Core Features & Use Cases

  • Pattern-driven optimization: Apply proven techniques to common query bottlenecks such as N+1 queries, inefficient joins, and missing indexes.
  • Indexing guidance: Select and implement appropriate index types (B-tree, GIN, BRIN) and composite/partial indexes to accelerate queries.
  • EXPLAIN-driven workflows: Interpreting EXPLAIN/EXPLAIN ANALYZE outputs to inform actionable changes.
  • Use Case: Debug slow production queries, redesign schemas for scalability, and optimize workloads with measurable latency improvements.

Quick Start

Run an optimization pass on your database by reviewing EXPLAIN plans and applying the recommended indexing strategies.

Frequently Asked Questions about sql-optimization-patterns

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

FAQPage Schema
How do I use EXPLAIN plan analysis to fix slow SQL queries?

Fix slow SQL queries by running EXPLAIN or EXPLAIN ANALYZE to inspect execution plans, then apply pattern-driven optimization like query rewrites and index creation to resolve bottlenecks such as inefficient joins.

What is the best way to choose indexing strategies for database performance optimization?

Choose indexing strategies by selecting appropriate index types like B-tree, GIN, or BRIN, and implementing composite or partial indexes to target specific query bottlenecks and accelerate database performance.

How do I resolve N+1 query problems and inefficient joins in PostgreSQL and MySQL?

Resolve N+1 query problems and inefficient joins in PostgreSQL and MySQL by applying pattern-driven optimization techniques that restructure query logic and introduce appropriate indexes for faster data retrieval.

Does this SQL optimization approach work for both PostgreSQL and MySQL databases?

Yes, the SQL optimization approach works for relational databases like PostgreSQL and MySQL, providing indexing strategies, EXPLAIN plan analysis, and query rewrite patterns suitable for development, staging, and production environments.

When should I use partitioning versus composite indexes for query optimization?

Use partitioning to manage large datasets by dividing tables into smaller segments, while composite indexes accelerate multi-column queries; the EXPLAIN plan output helps determine which strategy best resolves the specific bottleneck.