sql-optimization-patterns

Analyze SQL execution plans and apply indexing strategies to optimize query performance.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill tackles slow database queries and inefficient database schemas, leading to dramatically improved application performance and reduced operational costs.

Core Features & Use Cases

  • Query Plan Analysis: Understand EXPLAIN output to pinpoint bottlenecks.
  • Indexing Strategies: Implement effective B-Tree, Hash, GIN, GiST, and BRIN indexes.
  • Query Optimization Patterns: Learn to eliminate N+1 queries, optimize pagination, aggregate efficiently, and refactor subqueries.
  • Advanced Techniques: Utilize materialized views, partitioning, and query hints for maximum performance.

Quick Start

Analyze the query plan for the SQL statement 'SELECT * FROM users WHERE email = '[email protected]';' to identify performance issues.

Frequently Asked Questions about sql-optimization-patterns

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

FAQPage Schema
How do I analyze EXPLAIN plan output to pinpoint SQL query bottlenecks?

To analyze EXPLAIN plan output, you systematically review the execution plan to identify performance bottlenecks like full table scans or inefficient joins. This process interprets relational database internals to pinpoint exact slow query issues.

What is the best way to eliminate N+1 queries and optimize SQL pagination?

The best way to eliminate N+1 queries and optimize SQL pagination is by applying specific query optimization patterns. This involves refactoring subqueries, aggregating efficiently, and leveraging strategic indexing to slash query times.

When do I need composite indexes or materialized views for database performance tuning?

You need composite indexes or materialized views for database performance tuning when facing slow queries on large datasets. These advanced techniques address schema design issues and maximize aggregation efficiency.

How do I implement effective B-Tree, Hash, and BRIN indexing strategies?

To implement effective B-Tree, Hash, GIN, GiST, and BRIN indexing strategies, you match the index type to your specific query patterns and data structures. This ensures strategic indexing that dramatically improves database speed.

Can I use query hints and partitioning to fix slow database schemas?

Yes, you can use query hints and partitioning to fix slow database schemas. These advanced techniques optimize SQL query performance by restructuring data storage and execution paths for maximum efficiency.