postgres-performance

Optimize PostgreSQL queries and data access with indexing, partitioning, and EXPLAIN ANALYZE.

Updated Dec 22, 2025
One-click install
npx skills add https://github.com/CJHarmath/claude-agents-skills --skill postgres-performance
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-performance
Source: https://github.com/CJHarmath/claude-agents-skills/tree/main/skills/postgres-performance
Command: npx skills add https://github.com/CJHarmath/claude-agents-skills --skill postgres-performance

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses PostgreSQL performance bottlenecks by providing patterns to optimize queries and data access.

Core Features & Use Cases

  • Query Optimization Workflow
  • Covering Indexes (Index-Only Scans)
  • Pagination at Scale
  • Batch Processing
  • Efficient Aggregations
  • Connection Pool Tuning
  • Read Replicas
  • Denormalization for Read Performance
  • Partitioning Large Tables
  • Caching Strategy
  • Performance Monitoring Queries

Quick Start

Begin by running an initial audit with pg_stat_statements and EXPLAIN ANALYZE to identify slow queries, then implement covering indexes and consider partitioning for large datasets, followed by enabling a caching layer and tuning the connection pool.

Frequently Asked Questions about postgres-performance

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

FAQPage Schema
How do I optimize slow PostgreSQL queries in a transactional application?

Optimize slow PostgreSQL queries by running an initial audit with pg_stat_statements and EXPLAIN ANALYZE to identify bottlenecks, then implement covering indexes for index-only scans and tune connection pooling to improve data access throughput.

What is the best way to handle PostgreSQL pagination at scale?

Handle PostgreSQL pagination at scale by adopting specialized pagination patterns that avoid offset overhead, combined with batch processing for large data modifications and partitioning large tables to reduce scan times.

When do I need partitioning for large PostgreSQL tables?

You need partitioning for large PostgreSQL tables when query performance degrades on massive datasets, applying partitioning strategies alongside denormalization for read performance and efficient aggregations to maintain analytics workload speed.

Does this PostgreSQL performance optimization approach work for analytics workloads?

Yes, this PostgreSQL performance optimization approach supports analytics workloads by utilizing read replicas, efficient aggregations, and caching strategies to reduce query execution time for heavy data access requirements.

How do I monitor PostgreSQL performance bottlenecks in production deployments?

Monitor PostgreSQL performance bottlenecks in production by executing performance monitoring queries and utilizing pg_stat_statements to track query execution plans, ensuring safe batch operations during deployment.

Why does my PostgreSQL query plan show a sequential scan instead of an index scan?

Your PostgreSQL query plan shows a sequential scan due to missing covering indexes; running EXPLAIN ANALYZE identifies the bottleneck, and adding covering indexes enables index-only scans to bypass heap fetches.