query-optimization

Identify and fix slow SQL queries using EXPLAIN ANALYZE analysis.

28|3|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/girijashankarj/cursor-handbook --skill query-optimization-girijashankarj
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: query-optimization
Source: https://github.com/girijashankarj/cursor-handbook/tree/main/.cursor/skills/database/query-optimization
Command: npx skills add https://github.com/girijashankarj/cursor-handbook --skill query-optimization-girijashankarj

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Identify the root causes of slow SQL queries and provide a repeatable workflow to optimize them, improving overall application responsiveness.

Core Features & Use Cases

  • Query profiling: capture query text, runtime, and plan details to identify bottlenecks.
  • Plan analysis: run EXPLAIN ANALYZE and highlight expensive steps.
  • Optimization guidance: suggest indexing, query rewrites, and pagination strategies.
  • Validation: benchmark before/after results to ensure correctness.

Quick Start

Analyze a slow query by running EXPLAIN ANALYZE, identify bottlenecks, and implement recommended optimizations.

Frequently Asked Questions about query-optimization

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

FAQPage Schema
How do I find the root cause of slow SQL queries in a production database?▼

Profile slow SQL queries by capturing query text, runtime, and execution plan details to identify bottlenecks, then run EXPLAIN ANALYZE to highlight expensive steps like missing indexes or high I/O operations.

What is the best way to use EXPLAIN ANALYZE for query optimization?▼

EXPLAIN ANALYZE profiles your SQL execution plan to identify bottlenecks. Use it to highlight expensive steps, which guides indexing, query rewrites, and pagination strategies to improve database performance.

How do I optimize expensive database joins and high I/O operations?▼

Optimize expensive database joins and high I/O operations by applying indexing recommendations, rewriting queries, and implementing pagination strategies, then validate improvements by benchmarking before and after results.

Does query optimization work for production workloads with missing indexes?▼

Yes, query optimization applies to production workloads. It addresses common scenarios like missing indexes and expensive joins by providing a repeatable workflow of profiling, plan analysis, and validation.

How do I validate database performance improvements after rewriting a slow query?▼

Validate database performance improvements by benchmarking before and after results. This ensures correctness after applying indexing, query rewrites, and pagination strategies to your SQL queries.