postgres-expert

Analyze PostgreSQL query plans and optimize slow SQL performance.

Updated Apr 23, 2025
One-click install
npx skills add https://github.com/ripgraphics/authorsinfo --skill postgres-expert-ripgraphics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-expert
Source: https://github.com/ripgraphics/authorsinfo/tree/main/.cursor/skills/postgres-expert
Command: npx skills add https://github.com/ripgraphics/authorsinfo --skill postgres-expert-ripgraphics

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill addresses complex PostgreSQL performance bottlenecks, optimization challenges, and advanced database administration tasks, ensuring your database runs efficiently and reliably.

Core Features & Use Cases

  • Query Optimization: Analyzes and optimizes slow-running SQL queries using EXPLAIN ANALYZE.
  • Indexing Strategies: Recommends and implements advanced indexing techniques (GIN, GiST, BRIN, partial, expression indexes) for optimal data retrieval.
  • JSONB Operations: Provides expertise in optimizing JSONB column queries and indexing.
  • Partitioning: Guides on implementing table partitioning for large datasets to improve query performance and manageability.
  • Connection Management: Assists with tuning max_connections and configuring PgBouncer for efficient connection pooling.
  • Replication & HA: Offers insights into setting up and monitoring PostgreSQL replication for high availability.
  • Use Case: A user is experiencing slow query times on a large table with JSONB data. This Skill can analyze the query plan, suggest appropriate GIN indexes for the JSONB column, and provide the SQL to create them.

Quick Start

Use the postgres-expert skill to analyze the performance of the following SQL query: SELECT * FROM users WHERE status = 'active';

Frequently Asked Questions about postgres-expert

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

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

To optimize slow PostgreSQL queries, you analyze the execution plan using EXPLAIN ANALYZE to identify bottlenecks like sequential scans, then apply SQL optimization techniques such as rewriting queries or adding targeted indexes to improve data retrieval efficiency.

What is the best indexing strategy for PostgreSQL JSONB columns?

The best indexing strategy for PostgreSQL JSONB columns involves using GIN indexes to efficiently query key-value pairs within JSONB data, dramatically accelerating retrieval times for complex document queries compared to full table scans.

How does table partitioning improve PostgreSQL performance for large datasets?

Table partitioning improves PostgreSQL performance by dividing large datasets into smaller, manageable physical partitions, allowing the query planner to scan only relevant partitions and significantly reducing query execution times for massive tables.

Can I configure PgBouncer for PostgreSQL connection pooling and high availability?

Yes, you can configure PgBouncer for PostgreSQL connection pooling to manage max_connections efficiently, reducing connection overhead and supporting high availability configurations alongside PostgreSQL replication setup.

When should I use advanced indexes like GIN, GiST, or BRIN in PostgreSQL?

You should use advanced indexes like GIN for JSONB operations, GiST for geometric or full-text search data, and BRIN for large ordered datasets, ensuring optimal data retrieval where standard B-tree indexes fall short.

Why does PostgreSQL replication setup matter for high availability?

PostgreSQL replication setup matters for high availability because it continuously copies data across nodes, ensuring database reliability and allowing failover if the primary server fails, minimizing downtime.