SQL Query Optimizer

Analyze SQL queries for performance issues and rewrite them with optimized execution plans.

9|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/Notysoty/openagentskills --skill sql-query-optimizer-notysoty
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: SQL Query Optimizer
Source: https://github.com/Notysoty/openagentskills/tree/main/skills/sql-query-optimizer
Command: npx skills add https://github.com/Notysoty/openagentskills --skill sql-query-optimizer-notysoty

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Analyze SQL queries for performance issues and rewrite them with optimized execution plans.

Core Features & Use Cases

  • Detection of anti-patterns: Identifies missing indexes, non-sargable predicates, subqueries, and unnecessary scans.
  • Optimized rewrites: Produces a side-by-side comparison of the original and optimized queries with plain-English explanations.
  • Use cases: Applies to slow production queries, complex ad hoc analyses, and PR reviews affecting database performance.

Quick Start

Provide the SQL query and context (database system and schemas) to generate an optimized version.

Frequently Asked Questions about SQL Query Optimizer

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

FAQPage Schema
How do I optimize slow SQL queries with missing indexes and table scans?

Optimize slow SQL queries by identifying missing indexes, non-sargable predicates, and subqueries, then rewriting the query to produce an optimized execution plan and a recommended index strategy.

What is a non-sargable predicate and how does it affect database performance?

A non-sargable predicate is a query condition that prevents the database from using an index efficiently, forcing unnecessary scans and degrading database performance by ignoring optimized execution paths.

Can I use this to review SQL changes in a pull request before production deployment?

Yes, you can use it to review SQL changes in a pull request by analyzing the queries for performance issues, detecting anti-patterns like subqueries, and returning optimized rewrites before deployment.

What is the best way to rewrite subqueries for complex ad hoc analyses?

The best way to rewrite subqueries for complex ad hoc analyses is to analyze the execution plan, identify unoptimized patterns, and rewrite the SQL query with side-by-side comparisons and plain-English explanations.

What context do I need to provide to optimize a slow production query?

To optimize a slow production query, you need to provide the original SQL query and its context, including the specific database system and table schemas, to accurately generate the rewritten query and index strategy.