sql-optimizer

Diagnose slow SQL queries by analyzing execution plans and recommending targeted fixes.

3|2|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/JayRHa/AgentSkills --skill sql-optimizer-jayrha
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimizer
Source: https://github.com/JayRHa/AgentSkills/tree/main/sql-optimizer
Command: npx skills add https://github.com/JayRHa/AgentSkills --skill sql-optimizer-jayrha

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Diagnoses and fixes slow SQL queries by reading execution plans, identifying dominant costs, and proposing concrete, minimal changes (indexing, query rewrites, or schema adjustments) to restore performance.

Core Features & Use Cases

  • Reads EXPLAIN/ANALYZE plans to locate bottlenecks (Seq Scans, high-cost joins, sorts) and recommends targeted fixes.
  • Proposes deterministic changes: indexing strategies (ordered, covering), query rewrites, and statistics refresh when needed.
  • Useful for production-grade SQL tuning across PostgreSQL, MySQL/MariaDB, SQL Server, and SQLite workloads.

Quick Start

Provide a slow SQL query or plan, and I will generate an actionable optimization workflow.

Frequently Asked Questions about sql-optimizer

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

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

To optimize slow SQL queries, analyze the EXPLAIN ANALYZE plan to locate bottlenecks like sequential scans and high-cost joins, then apply targeted indexing or query rewrites to achieve verifiable performance improvements.

What is the best way to fix high-cost joins and sorts in PostgreSQL?

The best way to fix high-cost joins and sorts in PostgreSQL is to evaluate the execution plan and apply covering indexes or query rewrites that minimize large sequential scans and reduce sorting overhead.

Does SQL query tuning work across MySQL and SQL Server databases?

SQL query tuning works across MySQL, SQL Server, PostgreSQL, and SQLite workloads by reading execution plans and proposing deterministic indexing strategies and query rewrites tailored for each specific platform.

When do I need to refresh statistics for query plan analysis?

You need to refresh statistics for query plan analysis when the database optimizer generates inefficient execution paths due to stale data distributions, ensuring accurate cost estimates before applying indexing or query rewrites.

Why does my SQL query execution plan show a sequential scan on a large table?

An execution plan shows a sequential scan on a large table when missing or ineffective indexes force the database to read all rows, requiring targeted indexing strategies or query rewrites to achieve a faster, explainable plan.