sql-optimization-patterns

Analyze EXPLAIN plans and apply indexing strategies for PostgreSQL and MySQL.

Updated Sep 10, 2025
One-click install
npx skills add https://github.com/cuoreinpace/bdeornelas.github.io --skill sql-optimization-patterns-cuoreinpace
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/cuoreinpace/bdeornelas.github.io/tree/main/plugins/developer-essentials/skills/sql-optimization-patterns
Command: npx skills add https://github.com/cuoreinpace/bdeornelas.github.io --skill sql-optimization-patterns-cuoreinpace

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill empowers users to diagnose and resolve slow database queries, significantly enhancing application performance and reducing database load.

Core Features & Use Cases

  • Query Analysis: Understand and interpret EXPLAIN query plans to identify bottlenecks.
  • Indexing Strategies: Learn to create and apply various index types (B-Tree, GIN, etc.) for optimal data retrieval.
  • Optimization Patterns: Implement proven techniques like eliminating N+1 queries, optimizing pagination, and efficient aggregation.
  • Use Case: A web application is experiencing slow load times due to inefficient database queries. This Skill can be used to analyze the problematic queries, identify missing indexes or poor join strategies, and provide actionable steps to optimize them.

Quick Start

Use the sql-optimization-patterns skill to analyze the EXPLAIN plan for the query 'SELECT * FROM users WHERE email = '[email protected]';'.

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 an EXPLAIN query plan to fix slow SQL queries?

To analyze an EXPLAIN query plan, you interpret the execution steps to identify bottlenecks like missing indexes or poor join strategies, enabling you to apply SQL optimization patterns and significantly reduce query times. The Skill provides guidance on reading these plans for PostgreSQL and MySQL.

What is the best way to eliminate N+1 queries and optimize SQL pagination?

The best way to eliminate N+1 queries and optimize SQL pagination is by implementing proven optimization patterns such as efficient aggregation and subquery optimization. This approach reduces database load and drastically improves application response times.

Does this SQL optimization guidance cover indexing strategies for both PostgreSQL and MySQL?

Yes, this SQL optimization guidance covers indexing strategies for both PostgreSQL and MySQL. It details how to create and apply various index types, such as B-Tree and GIN, to achieve optimal data retrieval and resolve slow database performance.

When should I use advanced SQL techniques like materialized views and partitioning?

You should use advanced SQL techniques like materialized views and partitioning when basic indexing strategies are insufficient to handle large dataset bottlenecks. These methods optimize data retrieval and aggregation, further slashing query times for complex database operations.

Why does my database query ignore the index I created for performance tuning?

Your database query might ignore an index due to common pitfalls in query analysis or suboptimal indexing strategies. By reviewing the EXPLAIN plan, you can identify why the index is bypassed and apply correct optimization patterns to enforce efficient data retrieval.