sql-optimization-patterns

Analyze EXPLAIN plans and optimize SQL queries for PostgreSQL and MySQL.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/ACGSpgp/ACGS --skill sql-optimization-patterns-acgspgp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/ACGSpgp/ACGS/tree/main/.agent/workflows/developer-essentials/1.0.0/skills/sql-optimization-patterns
Command: npx skills add https://github.com/ACGSpgp/ACGS --skill sql-optimization-patterns-acgspgp

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps you dramatically improve database performance by mastering SQL query optimization, effective indexing strategies, and the analysis of query execution plans.

Core Features & Use Cases

  • Query Analysis: Understand EXPLAIN output to pinpoint bottlenecks.
  • Indexing Strategies: Learn to create and use various index types (B-Tree, GIN, etc.) for maximum efficiency.
  • Optimization Patterns: Implement techniques to avoid N+1 queries, optimize pagination, and improve aggregations.
  • Use Case: When a critical report is taking too long to load, use this Skill to analyze the slow query, identify missing indexes, and rewrite the query for sub-second performance.

Quick Start

Analyze the EXPLAIN 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 read an EXPLAIN plan to fix slow SQL queries?

An EXPLAIN plan reveals execution bottlenecks like sequential scans, helping you pinpoint missing indexes and rewrite slow SQL queries for sub-second database performance.

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

Eliminating N+1 queries and optimizing pagination requires implementing specific SQL optimization patterns like eager loading and keyset pagination to minimize database round trips.

How do I choose the right indexing strategies for MySQL query performance tuning?

Choosing the right indexing strategies involves selecting appropriate index types like B-Tree or GIN based on query patterns to maximize MySQL database performance tuning efficiency.

When should I use materialized views or partitioning for SQL aggregation optimization?

Use materialized views and partitioning for SQL aggregation optimization when dealing with large datasets where standard indexing cannot sufficiently reduce query execution time.

Does this SQL optimization guidance work for both PostgreSQL and MySQL environments?

Yes, this SQL optimization guidance covers best practices and common pitfalls specifically tailored for enhancing database performance in both PostgreSQL and MySQL environments.