sql-optimization

Analyze SQL execution plans and recommend indexes across relational databases.

Updated Mar 6, 2026
One-click install
npx skills add https://github.com/pczhao1210/reuseable-agents-and-skills --skill sql-optimization-pczhao1210
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization
Source: https://github.com/pczhao1210/reuseable-agents-and-skills/tree/main/.agents/skills/sql-optimization
Command: npx skills add https://github.com/pczhao1210/reuseable-agents-and-skills --skill sql-optimization-pczhao1210

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Slow or resource-heavy SQL queries caused by poor query patterns, suboptimal indexes, inefficient pagination, and lack of monitoring guidance, leading to high latency and increased database load. This Skill provides actionable, database-agnostic advice to identify bottlenecks and convert anti-patterns into efficient, maintainable SQL.

Core Features & Use Cases

  • Query performance analysis: Interpret execution plans, recommend rewrites, and replace correlated subqueries with window functions or joins where appropriate.
  • Indexing and schema guidance: Propose composite, partial, and covering indexes tailored to query patterns and advise on avoiding over-indexing.
  • Pagination, aggregation, and batching: Recommend cursor or ID-based pagination, optimized aggregation queries, and bulk operation strategies to reduce overhead.
  • Use case: Improve an orders reporting query that currently does full table scans by suggesting selective indexing, JOIN restructuring, and a cursor-based pagination approach to reduce query time and resource consumption.

Quick Start

Analyze the selected slow SQL query, identify the primary bottlenecks, and provide concrete index, rewrite, and monitoring recommendations.

Frequently Asked Questions about sql-optimization

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

FAQPage Schema
How do I analyze an SQL execution plan to fix slow query performance?

For SQL pagination optimization, implement cursor or ID-based pagination strategies instead of traditional offset methods. This approach significantly reduces overhead and resource consumption on large datasets by avoiding the scanning of preceding rows.

What is the best way to design indexes for complex SQL queries?

The best way to design SQL indexes for complex queries is tailoring composite, partial, and covering indexes to match specific query patterns. This Skill provides indexing guidance to improve selective filtering while advising on avoiding over-indexing penalties.

Does this SQL query optimization approach work with PostgreSQL and Oracle?

Yes, this SQL query optimization approach works with PostgreSQL and Oracle. It provides database-agnostic advice applicable across MySQL, SQL Server, and other relational SQL systems for execution plan analysis, aggregation optimization, and batch operations.

How do I optimize SQL aggregation and batch operations to reduce database load?

To optimize SQL aggregation and batch operations, apply bulk operation strategies and query rewrites to minimize transaction overhead. This Skill recommends optimized aggregation queries and practical performance-testing checklists to reduce high database load.