database-optimization

Analyze SQL queries with EXPLAIN ANALYZE and optimize indexing strategies.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/ThePhoenixAgency/Phoenix-Agents-Marketplace --skill database-optimization-thephoenixagency
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimization
Source: https://github.com/ThePhoenixAgency/Phoenix-Agents-Marketplace/tree/main/skills/database-optimization
Command: npx skills add https://github.com/ThePhoenixAgency/Phoenix-Agents-Marketplace --skill database-optimization-thephoenixagency

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses common database performance bottlenecks, including inefficient query planning, missing indexes, the N+1 query problem, and suboptimal connection pooling.

Core Features & Use Cases

  • Indexing Strategies: Provides guidance on when and how to create effective database indexes (e.g., B-tree, Hash, GIN).
  • N+1 Prevention: Demonstrates techniques like eager loading to avoid the performance pitfall of executing one query per iteration.
  • Connection Pooling: Offers best practices for configuring connection pool sizes and timeouts.
  • Query Analysis: Shows how to use EXPLAIN ANALYZE for performance diagnostics.
  • Use Case: A developer is experiencing slow response times on their web application. They can use this Skill to analyze their database queries, identify missing indexes, and refactor their code to prevent N+1 issues, significantly improving application speed.

Quick Start

Analyze the performance of the provided SQL query using EXPLAIN ANALYZE.

Frequently Asked Questions about database-optimization

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

FAQPage Schema
How do I fix the N+1 query problem in my web application?

To fix the N+1 query problem, you should use eager loading techniques to fetch related records in a single query rather than executing one query per iteration. This refactoring prevents performance bottlenecks and significantly improves web application speed.

How do I use EXPLAIN ANALYZE for PostgreSQL query performance tuning?

You use EXPLAIN ANALYZE to execute PostgreSQL queries and retrieve a diagnostic execution plan, revealing inefficient query planning and bottlenecks. Analyzing this output helps identify missing indexes and optimize overall database performance.

What are the best indexing strategies for relational database performance?

Effective database indexing strategies involve creating specific index types like B-tree, Hash, or GIN based on your query patterns. Proper indexes resolve missing index bottlenecks and accelerate data retrieval in relational database systems.

What are the best practices for configuring database connection pooling?

Database connection pooling best practices involve properly configuring pool sizes and timeouts to manage connections efficiently. This prevents connection exhaustion and ensures optimal resource allocation for your web application.

Why is my PostgreSQL database experiencing slow response times?

Slow PostgreSQL response times are typically caused by inefficient query planning, missing indexes, the N+1 query problem, or suboptimal connection pooling. Diagnosing your SQL with EXPLAIN ANALYZE helps identify and resolve these specific performance bottlenecks.