sql-optimization-patterns

Identify and implement SQL optimization patterns for slow queries.

1|1|Updated Jul 29, 2025
One-click install
npx skills add https://github.com/M-Abdullah07/Pharmacy-Billing-App --skill sql-optimization-patterns-m-abdullah07
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/M-Abdullah07/Pharmacy-Billing-App/tree/main/.agent/skills/sql-optimization-patterns
Command: npx skills add https://github.com/M-Abdullah07/Pharmacy-Billing-App --skill sql-optimization-patterns-m-abdullah07

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

SQL performance suffers from slow queries, inefficient joins, and missing or misused indexes. This Skill provides systematic approaches to identify bottlenecks, optimize queries, and apply indexing strategies to speed up data retrieval.

Core Features & Use Cases

  • EXPLAIN-driven optimization: interpret query plans to pinpoint bottlenecks and verify improvements.
  • Indexing strategies: design and apply appropriate B-Tree, GIN, GiST, and partial indexes to accelerate common queries.
  • Query pattern guidance: rewrite and refactor queries to reduce N+1 problems and improve join performance.
  • Use Case: performance tuning for a PostgreSQL-based analytics workload or a MySQL transactional store.

Quick Start

Provide a slow SQL query and I will optimize it using indexing, EXPLAIN analysis, and pattern-based 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 EXPLAIN plans?

To optimize slow SQL queries, you interpret EXPLAIN plans to pinpoint bottlenecks like inefficient joins or missing indexes. This Skill analyzes query plans to identify performance issues and applies pattern-based rewrites to verify improvements and boost data retrieval speed.

What are the best indexing strategies for PostgreSQL and MySQL performance tuning?

The best indexing strategies for PostgreSQL and MySQL involve designing and applying appropriate B-Tree, GIN, GiST, and partial indexes. This Skill helps you select and implement the correct index types to accelerate common queries and reduce latency in production systems.

How do I fix N+1 query problems and improve join performance?

Fixing N+1 query problems and improving join performance requires rewriting and refactoring SQL queries. This Skill provides query pattern guidance to reduce N+1 issues, optimize inefficient joins, and systematically refactor queries for faster data retrieval.

Does this SQL optimization approach work for both transactional and analytics workloads?

Yes, this SQL optimization approach works for both transactional and analytics workloads. It applies to database design and query performance tuning across PostgreSQL-based analytics workloads and MySQL transactional stores requiring low-latency data access.

Why is my SQL query still slow after adding a B-Tree index?

Your SQL query might remain slow after adding a B-Tree index due to misused indexes, inefficient joins, or N+1 problems. By analyzing EXPLAIN plans, you can identify these bottlenecks and apply alternative indexing strategies like GIN, GiST, or partial indexes.