sql-optimization

Analyze SQL execution plans and recommend indexes and query rewrites.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/mmahalwy/cooper --skill sql-optimization-mmahalwy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sql-optimization
Source: https://github.com/mmahalwy/cooper/tree/main/.agents/skills/sql-optimization
Command: npx skills add https://github.com/mmahalwy/cooper --skill sql-optimization-mmahalwy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps developers and DBAs identify and fix slow queries, inefficient indexes, and poor data-access patterns that cause high latency and excessive resource usage across SQL databases.

Core Features & Use Cases

  • Execution Plan Analysis: Interpret execution plans and suggest rewrites or join/order changes to eliminate full scans and high-cost operators.
  • Index Strategy & Management: Recommend composite, partial, covering indexes and advise on index ordering and trade-offs for read/write patterns.
  • Pagination, Aggregation & Batch Patterns: Replace OFFSET pagination with cursor or ID-based approaches, consolidate aggregations, and propose batch operations or temporary-table strategies for large datasets.
  • Real-world Example: Tune an orders-report query by adding indexes on created_at and customer_id, rewriting correlated subqueries into window functions or joins, and switching to cursor-based pagination to dramatically reduce response time.

Quick Start

Ask the sql-optimization assistant to analyze this query and recommend indexes and rewrites to improve performance.

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 execution plan to fix slow SQL queries?▼

Execution plan analysis identifies high-cost operators and full scans to suggest query rewrites, join order changes, and index strategies that eliminate inefficiencies causing slow SQL queries and high database latency.

What's the best way to replace OFFSET pagination for large datasets in PostgreSQL?▼

Replacing OFFSET pagination with cursor or ID-based approaches in PostgreSQL and other SQL databases prevents scanning skipped rows, dramatically reducing latency and resource usage on large datasets.

Does this SQL query optimization approach work with MySQL and Oracle?▼

Yes, this query optimization approach applies to MySQL, PostgreSQL, SQL Server, Oracle, and other SQL databases, analyzing execution plans and recommending indexes, pagination, and batch strategies across platforms.

When should I use composite or covering indexes for database performance?▼

Use composite, partial, or covering indexes when index strategy analysis reveals specific read/write patterns, trading minor write overhead for improved query latency and reduced full table scans.

How do I consolidate SQL aggregations and batch operations to reduce database load?▼

Consolidate SQL aggregations and propose batch operations or temporary-table strategies to reduce database load, replacing correlated subqueries with window functions or joins to minimize resource consumption.