sql-optimization-patterns

Analyze EXPLAIN output and optimize queries with indexing strategies for improved performance on MySQL and PostgreSQL databases.

Updated Nov 15, 2025
One-click install
npx skills add https://github.com/geinala/entry --skill sql-optimization-patterns-geinala
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/geinala/entry/tree/main/.agents/skills/sql-optimization-patterns
Command: npx skills add https://github.com/geinala/entry --skill sql-optimization-patterns-geinala

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Slow SQL queries cripple application performance; this Skill provides proven strategies to diagnose, optimize, and accelerate database operations.

Core Features & Use Cases

  • EXPLAIN plan analysis to understand query behavior and identify bottlenecks.
  • Indexing strategies (B-Tree, partial, expression, covering) and query rewriting to reduce latency.
  • Use Case: A reporting dashboard with large tables can apply these patterns to dramatically cut execution time and database load.

Quick Start

Run the included SQL optimization patterns on your slow queries to begin improving 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 analyze EXPLAIN plans to fix slow SQL queries?

Analyze EXPLAIN plans to identify query bottlenecks by examining execution behavior, enabling you to apply targeted indexing strategies and query rewriting to reduce latency in PostgreSQL and MySQL workloads.

What is the best way to design indexes for large MySQL and PostgreSQL tables?

The best way to design indexes involves applying B-Tree, partial, expression, or covering indexes based on your query patterns, dramatically cutting execution time and reducing database load for large reporting tables.

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

Yes, these SQL optimization patterns apply across both PostgreSQL and MySQL workloads, covering execution plans, index design, partitioning, and query rewriting to drive performance gains.

How do I rewrite SQL queries to improve database performance?

Rewrite SQL queries by combining EXPLAIN plan analysis with indexing strategies to reduce latency, applying proven optimization patterns via scripts or guidance to accelerate slow database operations.

When should I use partitioning instead of indexing for query optimization?

Use partitioning alongside indexing when managing large tables where query rewriting and covering indexes are insufficient, applying these optimization patterns to further reduce execution time and database load.