optimize-sql-query

Diagnose slow SQL queries by analyzing EXPLAIN ANALYZE execution plans.

9|3|Updated Jun 13, 2026
One-click install
npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill optimize-sql-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: optimize-sql-query
Source: https://github.com/Sir-chawakorn/sanook-cli/tree/main/skills/optimize-sql-query
Command: npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill optimize-sql-query

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses performance bottlenecks in database queries by identifying inefficient execution plans and providing actionable optimization strategies.

Core Features & Use Cases

  • Execution Plan Analysis: Evaluates EXPLAIN ANALYZE output to pinpoint bottlenecks like sequential scans, disk spills, and missing indexes.
  • Optimization Recommendations: Suggests specific index improvements, query rewrites, and configuration adjustments to reduce latency.
  • Verification: Ensures performance gains are measured and logically equivalent to the original query.

Quick Start

Provide the SQL query and its EXPLAIN ANALYZE output to the optimize-sql-query skill to receive a detailed performance improvement plan.

Frequently Asked Questions about optimize-sql-query

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

FAQPage Schema
How do I diagnose slow SQL queries using execution plans?

To diagnose slow SQL queries, analyze EXPLAIN ANALYZE output to pinpoint bottlenecks like sequential scans, disk spills, and inefficient join orders. This identifies exact performance degradation points for targeted optimization.

What's the best way to optimize database performance through query tuning?

The best way to optimize database performance is applying targeted recommendations for index creation, query rewriting, and partition pruning. This reduces latency by eliminating inefficient execution paths identified in the query plan.

What do I need to provide to analyze and accelerate slow SQL queries?

You need to provide the SQL query and its EXPLAIN ANALYZE output. Access to representative dataset statistics is also required to verify optimization effectiveness and ensure performance gains are measured.

Why does my SQL query have high latency despite missing indexes?

High latency often occurs because missing indexes force sequential scans, causing disk spills. Analyzing the execution plan identifies these exact bottlenecks so you can create targeted indexes to accelerate the query.

How do I verify SQL query optimization effectiveness after rewriting?

To verify optimization effectiveness, compare the EXPLAIN ANALYZE output of the rewritten query against the original. This ensures performance gains are measured and the new query remains logically equivalent to the original.