sql-optimization-patterns

Analyze SQL execution plans and apply indexing strategies to optimize database queries.

4|2|Updated Jan 7, 2026
One-click install
npx skills add https://github.com/3commas-io/commas-claude --skill sql-optimization-patterns-3commas-io
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/3commas-io/commas-claude/tree/main/skills/sql-optimization-patterns
Command: npx skills add https://github.com/3commas-io/commas-claude --skill sql-optimization-patterns-3commas-io

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps you diagnose and fix slow database queries, significantly improving application speed and reducing resource consumption.

Core Features & Use Cases

  • Query Plan Analysis: Understand EXPLAIN output to identify bottlenecks.
  • Indexing Strategies: Learn to create effective indexes (B-Tree, GIN, etc.) for faster data retrieval.
  • Query Optimization Patterns: Apply techniques like eliminating N+1 queries, optimizing pagination, and efficient aggregation.
  • Use Case: When a critical report takes minutes to load, use this Skill to analyze the query plan, add appropriate indexes, and rewrite the query for sub-second performance.

Quick Start

Analyze the query plan for the following SQL statement: SELECT * FROM users WHERE email = '[email protected]';

Frequently Asked Questions about sql-optimization-patterns

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

FAQPage Schema
How do I fix slow SQL queries?

Fix slow SQL queries by analyzing execution plans with EXPLAIN, identifying bottlenecks, and rewriting queries or adding indexes to reduce database load and improve performance.

What's the best way to eliminate N+1 query problems?

Eliminate N+1 query problems by applying SQL optimization patterns like efficient aggregation and cursor-based pagination to batch data retrieval and reduce redundant database requests.

How can I use indexing strategies to improve database performance?

Improve database performance by creating effective indexes such as B-Tree or GIN indexes, which accelerate data retrieval and resolve slow query execution times identified in the query plan.

Do I need to understand SQL execution plans to optimize database performance?

Yes, understanding SQL execution plans is required to identify bottlenecks, analyze index usage, and apply query optimization patterns effectively for schema design and database load reduction.

Can this skill help optimize SQL pagination?

Yes, this skill provides optimization patterns for SQL pagination, specifically by implementing cursor-based pagination techniques to replace slow offset queries and reduce database load.

Why does my database report take minutes to load?

Database reports take minutes to load due to missing indexes, N+1 queries, or poor schema design, which you diagnose by analyzing the SQL query plan and applying optimization patterns.