postgresql-optimization

Analyze EXPLAIN ANALYZE output and tune PostgreSQL indexes and configuration.

181|30|Updated Nov 16, 2025
One-click install
npx skills add https://github.com/curiositech/some_claude_skills --skill postgresql-optimization-curiositech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-optimization
Source: https://github.com/curiositech/some_claude_skills/tree/main/.claude/skills/postgresql-optimization
Command: npx skills add https://github.com/curiositech/some_claude_skills --skill postgresql-optimization-curiositech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses slow database performance, inefficient queries, and suboptimal PostgreSQL configurations, ensuring your database operates at its maximum potential.

Core Features & Use Cases

  • Query Optimization: Analyzes EXPLAIN ANALYZE output to identify and fix bottlenecks.
  • Indexing Strategies: Recommends and creates optimal indexes (B-tree, GIN, GiST, etc.) for various query patterns.
  • Schema Design: Advises on normalization, denormalization, and efficient data types like JSONB.
  • Configuration Tuning: Optimizes PostgreSQL parameters for memory, connections, and I/O.
  • Use Case: A web application is experiencing slow load times due to database queries. This Skill can analyze the slow queries, suggest appropriate indexes, and tune PostgreSQL settings to significantly improve response times.

Quick Start

Use the postgresql-optimization skill to analyze the following slow query and suggest index improvements.

Frequently Asked Questions about postgresql-optimization

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

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

PostgreSQL query optimization uses EXPLAIN ANALYZE output to identify execution bottlenecks like sequential scans or nested loops. By interpreting the execution plan, you can pinpoint slow operations and apply targeted indexing or schema adjustments to significantly reduce query latency.

What are the best indexing strategies for PostgreSQL performance tuning?

PostgreSQL indexing strategies involve selecting the right index types—B-tree for standard equality and range queries, GIN for full-text search and array operations, and GiST for geometric data. Choosing the correct index type matches your specific query patterns and accelerates data retrieval.

When do I need to tune PostgreSQL configuration parameters for better database performance?

PostgreSQL configuration tuning is needed when experiencing high connection contention, memory pressure, or disk I/O bottlenecks. Adjusting parameters like shared memory allocations and connection pooling settings ensures the database operates efficiently under production-grade workloads.

How does schema design with JSONB affect PostgreSQL database performance?

Schema design directly impacts PostgreSQL performance, and using JSONB allows flexible semi-structured data storage with indexing support. Proper normalization, denormalization, and efficient data type selection reduce storage overhead and improve query execution speed.

Can I use partitioning to fix PostgreSQL lock contention and slow queries?

PostgreSQL partitioning addresses lock contention and slow queries on large tables by dividing data across smaller physical partitions. This reduces scan times and isolates lock contention, improving concurrent query throughput for high-volume production databases.

What is the best way to resolve PostgreSQL connection pooling issues?

Resolving PostgreSQL connection pooling issues involves optimizing configuration parameters and managing connection limits to prevent pool exhaustion. Proper tuning ensures efficient connection reuse, reduces overhead from excessive client connections, and stabilizes application response times.