sql-optimization

Analyze EXPLAIN plans and optimize SQL queries for PostgreSQL and MySQL.

1|Updated Jan 6, 2026
One-click install
npx skills add https://github.com/hyukudan/ai-skills --skill sql-optimization-hyukudan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization
Source: https://github.com/hyukudan/ai-skills/tree/main/examples/skills/sql-optimization
Command: npx skills add https://github.com/hyukudan/ai-skills --skill sql-optimization-hyukudan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps users diagnose and resolve slow SQL query performance issues, reducing database load and improving application responsiveness.

Core Features & Use Cases

  • EXPLAIN Plan Analysis: Understand query execution plans for PostgreSQL and MySQL.
  • Indexing Strategies: Learn when and how to create effective indexes, including composite and partial indexes.
  • Query Pattern Optimization: Identify and refactor common anti-patterns like N+1 queries and inefficient pagination.
  • Use Case: A developer is experiencing slow load times on a dashboard that queries a large orders table. They can use this Skill to analyze the EXPLAIN ANALYZE output, identify missing indexes on customer_id and status columns, and rewrite the query for better performance.

Quick Start

Use the sql-optimization skill to analyze an EXPLAIN ANALYZE output for a slow query.

Frequently Asked Questions about sql-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I interpret an EXPLAIN plan to fix slow SQL queries?

Interpreting an EXPLAIN plan involves analyzing execution paths for PostgreSQL and MySQL to identify bottlenecks. This Skill helps read these outputs to diagnose slow SQL queries and apply indexing or query rewriting for better performance.

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

The best way to optimize N+1 queries and inefficient pagination is by identifying these common anti-patterns and rewriting the query logic. This Skill guides you through refactoring these patterns to reduce database load.

When do I need composite or partial indexes for database optimization?

You need composite or partial indexes when querying large tables with multiple filter conditions or specific subsets of data. This Skill provides indexing strategies to determine exactly when and how to create effective indexes for query tuning.

Does this SQL query tuning approach work with both PostgreSQL and MySQL?

Yes, this SQL query tuning approach works with both PostgreSQL and MySQL. It provides comprehensive guidance on interpreting execution plans, indexing strategies, and join optimization specific to these database systems.

How do I optimize SQL joins for database-intensive applications?

To optimize SQL joins for database-intensive applications, you must analyze execution plans and apply specific join optimization techniques. This Skill facilitates performance tuning by guiding you through join refactoring and anti-pattern avoidance.