sql-optimization-patterns

Analyze slow SQL queries using EXPLAIN plans and indexing strategies.

3|1|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/duanbiao2000/obsidianDoc26 --skill sql-optimization-patterns-duanbiao2000
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/duanbiao2000/obsidianDoc26/tree/main/agents-main/plugins/developer-essentials/skills/sql-optimization-patterns
Command: npx skills add https://github.com/duanbiao2000/obsidianDoc26 --skill sql-optimization-patterns-duanbiao2000

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

Slow SQL queries and poorly designed schemas cause latency, high load, and unpredictable performance.

Core Features & Use Cases

  • Query plan analysis with EXPLAIN to identify bottlenecks and guide indexing decisions.
  • Implement robust indexing strategies (B-Tree, BRIN, GIN, etc.) and optimized join patterns to reduce execution time.
  • Pattern-driven optimization for N+1 queries, pagination, aggregation, and subqueries to improve scalability.

Quick Start

Run a slow query through EXPLAIN ANALYZE, review the plan, and apply the recommended indexing and rewrite patterns to achieve faster results.

Frequently Asked Questions about sql-optimization-patterns

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

FAQPage Schema
How do I optimize slow SQL queries using execution plans?

Reduce N+1 query latency by applying pattern-driven optimization techniques for pagination and subqueries, implementing robust indexing strategies like B-Tree or GIN to improve scalability.

What is the best way to interpret EXPLAIN plans for PostgreSQL and MySQL?

Interpret EXPLAIN plans by identifying sequential scans, high cost operations, and missing indexes, which guides indexing decisions and query rewrites to improve database performance.

When do I need different indexing strategies like BRIN or GIN for database optimization?

You need different indexing strategies like BRIN or GIN when optimizing schema design for growing datasets, as specific index types target distinct query patterns and join operations to reduce execution time.

Can I use these query rewrite patterns for pagination and aggregation issues?

Yes, you can use pattern-driven optimization to resolve pagination and aggregation bottlenecks, rewriting subqueries and applying optimized join patterns to achieve faster query results.

Why does my database performance degrade as my app's dataset grows?

Database performance degrades with growing datasets due to poorly designed schemas and slow queries lacking proper indexing, causing high load and unpredictable latency that requires query plan analysis to resolve.