sql-optimization-patterns

Analyze PostgreSQL execution plans and optimize SQL query performance.

23|2|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/herdiansah/Antigravity-Skills-Master --skill sql-optimization-patterns-herdiansah
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/herdiansah/Antigravity-Skills-Master/tree/main/.agent/skills/sql-optimization-patterns
Command: npx skills add https://github.com/herdiansah/Antigravity-Skills-Master --skill sql-optimization-patterns-herdiansah

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill addresses slow database queries and inefficient database schemas by providing systematic optimization techniques, indexing strategies, and methods for analyzing query execution plans.

Core Features & Use Cases

  • Query Plan Analysis: Understand EXPLAIN output to identify bottlenecks.
  • Indexing Strategies: Learn to create effective B-Tree, Hash, GIN, GiST, and BRIN indexes.
  • Query Optimization Patterns: Apply techniques to avoid N+1 queries, optimize pagination, aggregate efficiently, and rewrite subqueries.
  • Use Case: When a critical report is taking minutes to load, use this skill to analyze the query plan, identify missing indexes, and rewrite the SQL for sub-second performance.

Quick Start

Analyze the execution plan for the following PostgreSQL query: 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 analyze PostgreSQL query execution plans to fix slow database operations?

To fix slow database operations, analyze PostgreSQL query execution plans using EXPLAIN output to identify performance bottlenecks. This skill guides you through interpreting the plan to apply systematic optimization techniques and targeted query rewriting.

What is the best way to resolve N+1 query problems and inefficient pagination in SQL?

The best way to resolve N+1 query problems and inefficient pagination is by applying specific query optimization patterns. This skill provides techniques to rewrite subqueries and aggregate data efficiently to eliminate redundant database requests.

How do I create effective indexing strategies using B-Tree, GIN, or BRIN indexes?

To create effective indexing strategies, you select appropriate index types like B-Tree, Hash, GIN, GiST, or BRIN based on your query patterns. This skill teaches you how to match indexing principles to your specific database performance metrics.

Can I use these SQL query tuning techniques for relational databases other than PostgreSQL?

Yes, while these SQL query tuning techniques focus on PostgreSQL features, the core principles of indexing strategies and execution plan analysis apply to other relational databases. Understanding SQL query execution is required to adapt the optimization patterns.

When should I not use a specific database index for query optimization?

You should not add a database index when the query execution plan shows the overhead of index maintenance outweighs read performance gains. This skill helps you analyze performance metrics to determine when query rewriting is better than indexing.