sql-optimization-patterns

Analyze EXPLAIN outputs to optimize slow SQL queries with indexing and rewrites.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/azap026/smetalabv3 --skill sql-optimization-patterns-azap026
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/azap026/smetalabv3/tree/main/.agent/skills/sql-optimization-patterns
Command: npx skills add https://github.com/azap026/smetalabv3 --skill sql-optimization-patterns-azap026

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This skill helps developers identify and fix slow SQL queries through structured optimization techniques, indexing, and plan analysis. The focus is on reducing execution time, lowering resource usage, and improving overall database responsiveness.

Core Features & Use Cases

  • EXPLAIN Analysis: Interpret execution plans to locate bottlenecks and guide optimizations.
  • Indexing Strategies: Design and tune indexes (including composite, partial, and expression indexes) to accelerate queries.
  • Query Optimization Patterns: Apply proven rewrites, batching, and data access improvements to eliminate common inefficiencies.
  • Use Case: When facing slow queries on large tables, apply this Skill to diagnose the root cause and implement a fast, reliable solution.

Quick Start

Run an EXPLAIN ANALYZE on a slow query, review the plan, and implement recommended index changes and query rewrites to boost performance.

Frequently Asked Questions about sql-optimization-patterns

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

FAQPage Schema
How do I optimize slow SQL queries using execution plans?

To optimize slow SQL queries, run an EXPLAIN ANALYZE to generate execution plans, interpret them to locate bottlenecks, and apply proven indexing and query rewriting patterns to reduce execution time.

What's the best way to design indexes for PostgreSQL query optimization?

For PostgreSQL query optimization, design and tune composite, partial, and expression indexes to accelerate data access, eliminating common inefficiencies and lowering resource usage on large tables.

Does this SQL optimization approach work with MySQL?

Yes, this SQL optimization approach works with MySQL and similar systems, applying database design, performance tuning, and debugging techniques to improve overall database responsiveness across platforms.

Why does query optimization require solid SQL knowledge?

Query optimization requires solid SQL knowledge because you must interpret EXPLAIN outputs accurately and implement recommended index changes and query rewrites to successfully fix slow queries.

What are the limitations of query rewriting for performance tuning?

Query rewriting for performance tuning requires access to EXPLAIN outputs and the ability to implement changes, meaning you must anticipate structural database modifications when applying batching and data access improvements.

How do I analyze an EXPLAIN plan to locate database bottlenecks?

To analyze an EXPLAIN plan, interpret the execution plan output to locate bottlenecks and guide optimizations, using structured optimization techniques to identify the root cause of slow queries on large tables.