sql-optimization-patterns

Analyze SQL query plans with EXPLAIN and apply indexing strategies.

Updated Dec 13, 2024
One-click install
npx skills add https://github.com/neo-picasso-2112/dotfiles --skill sql-optimization-patterns-neo-picasso-2112
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/neo-picasso-2112/dotfiles/tree/main/.claude/skills/sql-optimization-patterns
Command: npx skills add https://github.com/neo-picasso-2112/dotfiles --skill sql-optimization-patterns-neo-picasso-2112

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Transform slow database queries into fast, predictable performance through systematic optimization, indexing strategies, and query plan analysis.

Core Features & Use Cases

  • EXPLAIN analysis for query plans to identify bottlenecks
  • Indexing strategies including B-tree, partial, expression, and specialized indexes
  • Query optimization patterns for joins, subqueries, and pagination to reduce latency
  • Best practices for monitoring and maintaining query performance in production
  • Use Case: Debug a slow report query by analyzing the plan and applying the recommended index

Quick Start

Analyze a slow query with EXPLAIN and implement targeted indexing to improve 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 analysis?

To optimize slow SQL queries, use EXPLAIN analysis to identify execution plan bottlenecks like sequential scans, then apply targeted indexing strategies and query rewriting to reduce latency. This systematic approach pinpoints exact performance issues.

What are the best indexing strategies for database performance optimization?

The best indexing strategies for database performance optimization include selecting B-tree, partial, expression, or specialized indexes based on query patterns. Choosing the appropriate index type targets specific filtering and joining operations.

Does this SQL optimization approach work with PostgreSQL and MySQL?

Yes, this SQL optimization approach works with PostgreSQL, MySQL, and other relational systems. It applies systematic query plan analysis and indexing strategies across various relational database platforms to improve application response times.

How do I fix slow pagination and aggregation queries in SQL?

Fix slow pagination and aggregation queries in SQL by applying specific optimization patterns that reduce latency. Implementing efficient pagination and aggregation patterns minimizes data scanning and improves overall query throughput.

When should I analyze a query plan to debug database performance issues?

You should analyze a query plan to debug database performance issues when application response times degrade or report queries run slow. EXPLAIN analysis reveals execution bottlenecks, guiding targeted index implementation for schema design.

What is the best way to optimize SQL joins and subqueries?

The best way to optimize SQL joins and subqueries is by applying query optimization patterns that restructure execution logic. Refactoring joins and subqueries reduces computational overhead and ensures predictable database performance.