sql-optimization-patterns

Automate SQL query optimization with patterns and checklists for PostgreSQL and MySQL.

4|2|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/0xKobold/0xkobolds --skill sql-optimization-patterns-0xkobold
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/0xKobold/0xkobolds/tree/main/.agents/skills/sql-optimization-patterns
Command: npx skills add https://github.com/0xKobold/0xkobolds --skill sql-optimization-patterns-0xkobold

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to diagnosing and solving slow SQL queries through systematic optimization, indexing, and query plan analysis. It enables practitioners to transform inefficient queries into high-performance ones using practical patterns and concrete examples.

Core Features & Use Cases

  • Explains EXPLAIN/ANALYZE concepts and how to interpret plans
  • Provides indexing strategies, including composite, partial, and expression indexes
  • Offers common optimization patterns for joins, pagination, aggregation, and subqueries
  • Includes practical examples for PostgreSQL and MySQL and a clear decision flow

Quick Start

Identify a slow query and apply EXPLAIN ANALYZE steps to guide indexing, joins, and query rewrites.

Frequently Asked Questions about sql-optimization-patterns

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

FAQPage Schema
How do I interpret EXPLAIN ANALYZE output to fix slow SQL queries?

SQL query optimization patterns cover join rewrites, pagination strategies, aggregation, and subquery flattening. This Skill provides concrete examples and decision flows to transform inefficient queries into high-performance ones across PostgreSQL and MySQL environments.

Does this SQL optimization approach work with both PostgreSQL and MySQL?

Yes, the SQL optimization approach works with both PostgreSQL and MySQL environments. It provides ready-to-execute examples, indexing strategies, and query tuning patterns specifically tailored for debugging performance issues across both database systems.

What is the best way to choose between composite, partial, and expression indexes?

The best way to choose indexes is by matching them to your query's filter, join, and grouping conditions. This Skill offers indexing strategies that explain when to apply composite, partial, or expression indexes for optimal database performance.

When should I not use query rewrites for SQL optimization?

You should avoid query rewrites when the existing query plan already utilizes optimal indexes and low-cost join operations. This Skill emphasizes using EXPLAIN ANALYZE first to verify that a performance bottleneck genuinely exists before applying structural changes.