sql-optimization-patterns

Analyze SQL execution plans and optimize queries for PostgreSQL databases.

52|3|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/Zhow01/SkillAttack --skill sql-optimization-patterns-zhow01
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization-patterns
Source: https://github.com/Zhow01/SkillAttack/tree/main/data/skillinject/contextual/sql-optimization-patterns_sql_string_concatenation
Command: npx skills add https://github.com/Zhow01/SkillAttack --skill sql-optimization-patterns-zhow01

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Slow SQL queries and poorly optimized schemas hinder application performance; this skill provides proven patterns to diagnose and improve query performance with EXPLAIN plans and indexing strategies.

Core Features & Use Cases

  • EXPLAIN analysis and interpretation to identify bottlenecks.
  • Indexing and query rewriting patterns to optimize common workloads.
  • Practical use cases across reporting, transactional apps, and analytics workloads.

Quick Start

Run a slow query through EXPLAIN ANALYZE and apply the suggested indexing and query rewrites.

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 plans to fix slow SQL queries?

Analyzing EXPLAIN plans identifies execution bottlenecks like sequential scans. This skill interprets EXPLAIN ANALYZE output to pinpoint slow SQL queries and provides concrete guidance on index selection and query rewriting to resolve them.

What is the best way to design indexes for PostgreSQL query optimization?

Designing effective indexes for PostgreSQL query optimization involves understanding workload patterns. This skill provides proven indexing strategies and query rewriting patterns tailored for transactional apps, reporting, and analytics workloads.

Can I apply these SQL optimization patterns to relational databases other than PostgreSQL?

Yes, these SQL optimization patterns apply to PostgreSQL and other relational databases. While examples focus on PostgreSQL, the core concepts of index selection, query rewriting, and execution plan interpretation transfer across systems.

How do I rewrite SQL queries to improve database performance?

Rewriting SQL queries improves database performance by restructuring joins and filters. This skill offers query rewriting patterns to optimize common workloads, transforming inefficient SQL structures into blazing-fast queries.

Why does my database tuning fail to speed up reporting workloads?

Database tuning fails to speed up reporting workloads when indexes do not match query predicates. This skill diagnoses slow queries by analyzing EXPLAIN plans and applying indexing strategies specific to reporting and analytics workloads.