query-optimization

Analyze EXPLAIN plans and rewrite slow SQL queries for better performance.

147|32|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill query-optimization-seb1n
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-optimization
Source: https://github.com/seb1n/awesome-ai-agent-skills/tree/main/database/query-optimization
Command: npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill query-optimization-seb1n

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill tackles the performance bottlenecks caused by slow database queries, ensuring applications run faster and more efficiently.

Core Features & Use Cases

  • Diagnose Slow Queries: Analyzes EXPLAIN plans to pinpoint performance issues like inefficient scans or missing indexes.
  • Optimize SQL: Rewrites queries and recommends optimal indexing strategies.
  • Fix ORM Issues: Identifies and resolves N+1 query problems in popular ORMs.
  • Use Case: An e-commerce site experiences slow product searches due to inefficient database queries. This Skill analyzes the problematic SQL, suggests adding a composite index on products(category, price), and rewrites the query for faster retrieval.

Quick Start

Analyze the provided slow SQL query and suggest optimizations.

Frequently Asked Questions about query-optimization

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

FAQPage Schema
How do I optimize slow SQL queries using EXPLAIN plans?

To optimize slow SQL queries, you analyze the database-specific EXPLAIN plans to pinpoint performance issues like inefficient table scans, then rewrite the queries and add optimal indexes to improve retrieval speed.

How do I fix N+1 query problems in Django and SQLAlchemy ORMs?

Fixing N+1 query problems in Django and SQLAlchemy ORMs requires interpreting the generated SQL to identify redundant fetching, then rewriting the ORM calls to ensure related data is loaded efficiently in a single query.

What is the best way to resolve slow database performance in an e-commerce search?

The best way to resolve slow database performance in an e-commerce search is by rewriting the problematic SQL query and adding composite indexes, such as on product category and price columns, for faster retrieval.

Do I need database-specific EXPLAIN commands to tune SQL queries?

Yes, you need database-specific EXPLAIN commands to tune SQL queries effectively, as interpreting these plans is required to accurately diagnose inefficient scans and recommend the correct indexing strategies.

Why does my ORM generate slow database queries that need query tuning?

Your ORM generates slow database queries needing query tuning when it creates inefficient scans or misses indexes, requiring analysis of the underlying SQL to rewrite the ORM logic and apply optimal indexing strategies.