sql-optimizer

Optimize SQL queries across PostgreSQL, MySQL, and SQLite with EXPLAIN plans.

Updated Mar 27, 2026
One-click install
npx skills add https://github.com/goodstoriesworld/coco-agent-skills --skill sql-optimizer-goodstoriesworld
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimizer
Source: https://github.com/goodstoriesworld/coco-agent-skills/tree/main/vendored/sql-optimizer
Command: npx skills add https://github.com/goodstoriesworld/coco-agent-skills --skill sql-optimizer-goodstoriesworld

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Efficiently optimize SQL queries to reduce execution time, lower resource usage, and improve reliability across database workloads.

Core Features & Use Cases

  • Query analysis with EXPLAIN plans across PostgreSQL, MySQL, and SQLite.
  • Index design guidance, including composite and partial indexes, to support common query patterns.
  • Identification of anti-patterns (e.g., N+1 queries, unnecessary sorts) with concrete fixes and rewritten queries.

Quick Start

Run the optimizer on your slow query to see an improved execution plan.

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 with complex JOINs?

To optimize slow SQL queries, you analyze execution plans and rewrite complex JOINs to reduce resource usage. This process identifies anti-patterns like unnecessary sorts and generates concrete query fixes for fast, reliable database performance.

What is an N+1 query anti-pattern and how do I fix it?

An N+1 query anti-pattern occurs when separate queries fetch related data in a loop instead of using a single JOIN. You fix it by identifying the redundant calls and rewriting the query to retrieve all necessary data in one optimized operation.

Does this SQL optimizer work with PostgreSQL, MySQL, and SQLite?

Yes, the SQL optimizer works with PostgreSQL, MySQL, and SQLite. It analyzes EXPLAIN plans and designs indexing strategies across these specific databases for both development and production performance tuning workloads.

When should I use composite or partial indexes for database optimization?

You should use composite or partial indexes for database optimization when supporting common query patterns that filter on multiple columns or specific subsets of data. Proper index design lowers execution time and improves query reliability across workloads.

What's the best way to reduce SQL execution time in production?

The best way to reduce SQL execution time in production is generating an optimized query plan with recommended indexes. This method eliminates unnecessary sorts and lowers resource usage for reliable performance tuning across database workloads.