sql-optimization-patterns

Analyzes SQL slow queries and recommends indexing and rewrite strategies.

7|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/Harmeet10000/skills --skill sql-optimization-patterns-harmeet10000
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/Harmeet10000/skills/tree/main/skills/database/sql-optimization-patterns
Command: npx skills add https://github.com/Harmeet10000/skills --skill sql-optimization-patterns-harmeet10000

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps DBAs and developers diagnose and fix slow SQL queries by teaching systematic optimization approaches, indexing strategies, and EXPLAIN plan analysis.

Core Features & Use Cases

  • Index design guidance for common patterns (composite, partial, expression-based indexes).
  • Query plan interpretation and rewrite recommendations to avoid full-table scans and expensive joins.
  • Use cases include optimizing reporting workloads, transactional queries, and data-heavy dashboards, with concrete examples and best practices.

Quick Start

Provide a slow-query example and this Skill will generate an indexing and query-rewrite plan for faster execution.

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 EXPLAIN plan analysis?

To optimize slow SQL queries, you analyze the EXPLAIN/ANALYZE plan to identify full-table scans and expensive joins, then apply indexing strategies and query rewriting to improve database performance.

What are the best indexing strategies for optimizing PostgreSQL and MySQL queries?

The best indexing strategies for optimizing PostgreSQL and MySQL queries involve designing composite, partial, and expression-based indexes to avoid full-table scans and accelerate data-heavy dashboard workloads.

How do I fix the N+1 query problem and optimize pagination in SQL?

To fix the N+1 query problem and optimize pagination in SQL, you rewrite the query execution patterns to eliminate redundant data fetching and apply common SQL optimization patterns for faster execution.

Can I use this SQL optimization approach for transactional queries and reporting workloads?

Yes, you can use this SQL optimization approach for transactional queries and reporting workloads by interpreting query plans and applying index design guidance to systematically improve execution speed.

Why does my SQL query trigger a full-table scan despite having an index?

Your SQL query triggers a full-table scan despite having an index because the query plan indicates the existing index is not optimal, requiring a query rewrite or a composite and expression-based index design.