sql-optimization-patterns

Analyze EXPLAIN output and apply indexing strategies to optimize SQL queries.

Updated Feb 16, 2026
One-click install
npx skills add https://github.com/Thedougler/agent-template --skill sql-optimization-patterns-thedougler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/Thedougler/agent-template/tree/main/.github/skills/sql-optimization-patterns
Command: npx skills add https://github.com/Thedougler/agent-template --skill sql-optimization-patterns-thedougler

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps you diagnose and resolve slow database queries, optimize database schemas, and improve overall application performance by leveraging advanced SQL optimization techniques.

Core Features & Use Cases

  • Query Plan Analysis: Understand EXPLAIN output to identify bottlenecks.
  • Indexing Strategies: Learn to create and use various index types effectively.
  • Query Optimization Patterns: Apply proven methods to rewrite inefficient queries.
  • Use Case: You're experiencing slow load times on your e-commerce site. Use this Skill to analyze your product listing query, identify missing indexes, and rewrite it for faster retrieval.

Quick Start

Use the sql-optimization-patterns skill to analyze the EXPLAIN output for the following PostgreSQL query: SELECT * FROM orders WHERE order_date > '2023-01-01';

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

Analyze EXPLAIN output to identify query execution bottlenecks like sequential scans or inefficient joins. This Skill helps interpret query plans to pinpoint missing indexes and rewrite queries for faster data retrieval.

What are the best indexing strategies for PostgreSQL performance tuning?

Effective indexing strategies for PostgreSQL performance tuning involve selecting appropriate index types like B-tree or GIN indexes. This Skill guides you in creating indexes that match your query patterns to reduce database load.

How do I rewrite inefficient SQL queries to reduce database load?

Rewrite inefficient SQL queries by applying proven optimization patterns to eliminate bottlenecks. This Skill provides query rewriting techniques that transform slow data retrieval operations into efficient execution plans.

When should I use GIN indexes versus B-tree indexes for query optimization?

Use GIN indexes for multi-valued data like arrays or full-text search, and B-tree indexes for standard range and equality queries. This Skill explains how to match index types to your specific query analysis needs.

Can I optimize database schema design for better SQL performance?

You can optimize database schema design for better SQL performance by structuring tables to support efficient data retrieval. This Skill addresses schema design for performance alongside query optimization and indexing strategies.

Why does my e-commerce product listing query take so long to execute?

Your e-commerce product listing query may take long due to missing indexes or inefficient query structures. This Skill helps analyze the query, identify missing indexes, and rewrite it for faster retrieval to resolve slow load times.