database-optimization

Analyze EXPLAIN ANALYZE output to resolve slow PostgreSQL queries.

Updated Mar 15, 2026
One-click install
npx skills add https://github.com/a53ali/ai-dev --skill database-optimization-a53ali
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimization
Source: https://github.com/a53ali/ai-dev/tree/main/skills/engineer/database-optimization
Command: npx skills add https://github.com/a53ali/ai-dev --skill database-optimization-a53ali

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps engineers identify and resolve slow database queries, optimizing performance and scalability.

Core Features & Use Cases

  • Slow Query Analysis: Utilizes EXPLAIN ANALYZE to diagnose and optimize slow queries.
  • Index Strategy: Provides guidance on creating and using indexes for optimal performance.
  • N+1 Query Detection and Resolution: Identifies and fixes N+1 query patterns in ORM-generated SQL.
  • Query Rewriting: Offers best practices for rewriting queries to improve performance.
  • PostgreSQL Maintenance: Recommends vacuuming and analyzing to maintain database health.
  • Connection Pooling: Discusses best practices for connection pooling to enhance performance.
  • Anti-Patterns: Identifies common anti-patterns in database queries and provides solutions.
  • Escalation Guidance: Offers advice on when to involve a DBA for complex issues.
  • Use Case: For an engineer dealing with a slow application that is identified to have a performance bottleneck in the database layer.

Quick Start

Run the database-optimization skill to analyze and optimize the performance of your database queries.

Frequently Asked Questions about database-optimization

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

FAQPage Schema
How do I analyze slow PostgreSQL queries using EXPLAIN ANALYZE output?

To analyze slow PostgreSQL queries, you evaluate the EXPLAIN ANALYZE execution plan to diagnose bottlenecks, propose indexing strategies, and rewrite inefficient SQL for optimal performance.

What is the best way to identify and fix N+1 query problems in an ORM?

Fixing N+1 query problems involves analyzing ORM-generated SQL to detect redundant fetches and rewriting the query pattern to batch data retrieval, eliminating database bottlenecks.

When do I need to run vacuuming and analyzing for PostgreSQL maintenance?

You need PostgreSQL maintenance like vacuuming and analyzing when query performance degrades, as these operations update planner statistics and reclaim storage to maintain database health.

Does query optimization work with connection pooling to improve database performance?

Query optimization works alongside connection pooling to enhance database performance by reducing execution overhead per transaction while minimizing connection establishment latency.

How do I know when to escalate database performance tuning issues to a DBA?

You escalate database performance tuning issues to a DBA when query rewriting and indexing strategies fail to resolve complex architectural bottlenecks or require advanced system-level configuration.