sql-optimization-patterns

Analyze EXPLAIN/ANALYZE plans and recommend indexes for PostgreSQL and MySQL queries.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

Core Features & Use Cases

  • EXPLAIN/ANALYZE guidance: Interpret query plans and identify bottlenecks across PostgreSQL, MySQL, and compatible systems.
  • Indexing strategies: Choose and design B-Tree, Hash, GIN, GiST, BRIN, composite and partial indexes to support common workloads.
  • Query optimization patterns: Avoid SELECT *, optimize JOINs, pagination, aggregation, subqueries, and use CTEs when appropriate.
  • Advanced techniques: Materialized views, table partitioning, and index-only scans to accelerate large datasets.
  • Best practices & monitoring: Build a repeatable workflow with ANALYZE/VACUUM, slow query logs, and regular maintenance.

Quick Start

Run the included analysis on a representative slow query and apply the recommended patterns to observe improvements. Start by running EXPLAIN ANALYZE on a slow query, then implement indexing changes and query rewrites, and finally re-measure 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 use EXPLAIN ANALYZE to optimize slow SQL queries?

SQL query optimization with EXPLAIN ANALYZE involves interpreting execution plans to identify bottlenecks like sequential scans. This skill guides you through reading query plans across PostgreSQL and MySQL to pinpoint latency sources before applying indexing or query rewrites.

What are the best indexing strategies for database performance tuning?

Indexing strategies for database performance tuning include choosing between B-Tree, Hash, GIN, GiST, BRIN, composite, and partial indexes. This skill helps you select and design indexes tailored to your specific workloads to accelerate large datasets.

Does this SQL optimization approach work with both PostgreSQL and MySQL?

Yes, this SQL optimization approach works with PostgreSQL, MySQL, and similar relational databases. It provides compatible EXPLAIN plan interpretation and indexing recommendations applicable across these specific relational database platforms.

What are common SQL query optimization patterns for JOINs and pagination?

Common SQL query optimization patterns include avoiding SELECT *, optimizing JOINs, improving pagination, restructuring subqueries, and using CTEs appropriately. This skill provides practical patterns to rewrite queries for lower latency.

When should I use advanced techniques like materialized views or table partitioning?

Advanced techniques like materialized views, table partitioning, and index-only scans should be used when optimizing large datasets that standard indexing cannot resolve. This skill applies these methods to accelerate read-heavy workloads and complex aggregations.

How do I build a repeatable workflow for database monitoring and maintenance?

Build a repeatable database performance workflow by combining slow query logs with regular ANALYZE and VACUUM maintenance. This skill outlines best practices to monitor, tune, and maintain scalable schemas continuously.