sql-optimization-patterns

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps users dramatically improve database performance by optimizing SQL queries, implementing effective indexing strategies, and analyzing query execution plans to eliminate slow-running queries.

Core Features & Use Cases

  • Query Plan Analysis: Understand EXPLAIN output to identify bottlenecks.
  • Indexing Strategies: Learn to create and use various index types (B-Tree, Hash, GIN, etc.) for different query needs.
  • Query Optimization Patterns: Apply techniques like eliminating N+1 queries, optimizing pagination, and efficient aggregation.
  • Use Case: When a critical report is taking too long to generate, use this Skill to analyze the EXPLAIN plan of the underlying SQL query, identify a missing index, create it, and re-run the query for a significant speed improvement.

Quick Start

Use the sql-optimization-patterns skill to analyze the EXPLAIN plan for the query 'SELECT * FROM orders WHERE created_at > NOW() - INTERVAL '30 days';'.

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

To analyze an EXPLAIN plan for slow SQL queries, you review the execution plan output to identify bottlenecks like sequential scans or inefficient joins. This Skill provides guidance on reading query plans to pinpoint missing indexes and resolve slow-running queries.

What is the best way to optimize SQL pagination for large datasets?

The best way to optimize SQL pagination is by applying specific query optimization patterns that avoid deep offset scans. This Skill details techniques for efficient pagination and aggregation to enhance database performance on large datasets.

How do I eliminate N+1 queries in my database application?

To eliminate N+1 queries, you apply specific query optimization patterns that consolidate multiple individual queries into batch operations. This Skill covers these patterns to resolve slow queries and improve application throughput.

Which index type should I use for my PostgreSQL or MySQL database?

Choosing the right index type for PostgreSQL or MySQL depends on your query needs, utilizing structures like B-Tree, Hash, or GIN. This Skill explains indexing strategies to create effective indexes for various database workloads.

When should I use materialized views and partitioning for query tuning?

You should use materialized views and partitioning for query tuning when dealing with complex aggregations or massive tables that cannot be optimized with indexes alone. This Skill includes these advanced techniques to enhance database performance.