postgres-expert

Optimize PostgreSQL queries, indexing, JSONB, partitioning, and replication.

Updated Mar 15, 2026
One-click install
npx skills add https://github.com/ariesanhthu/HiveK --skill postgres-expert-ariesanhthu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-expert
Source: https://github.com/ariesanhthu/HiveK/tree/main/.agent/skills/postgres-expert
Command: npx skills add https://github.com/ariesanhthu/HiveK --skill postgres-expert-ariesanhthu

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill addresses complex PostgreSQL performance tuning, advanced feature utilization, and database administration challenges, ensuring optimal database health and efficiency.

Core Features & Use Cases

  • Query Optimization: Analyzes and optimizes slow-running SQL queries using EXPLAIN ANALYZE.
  • Indexing Strategies: Recommends and implements advanced indexing (GIN, GiST, BRIN, partial, expression) for various data types and query patterns.
  • JSONB Operations: Optimizes JSONB data storage and retrieval with appropriate indexing.
  • Partitioning: Guides on implementing table partitioning for large datasets to improve query performance and manageability.
  • Connection Management: Assists with configuring PgBouncer and tuning max_connections to prevent exhaustion.
  • Autovacuum Tuning: Optimizes autovacuum settings to combat bloat and maintain performance.
  • Replication & HA: Provides insights into setting up and monitoring PostgreSQL replication for high availability.
  • Use Case: A user is experiencing slow query performance on a large table with JSONB data. This Skill can analyze the EXPLAIN output, suggest appropriate GIN indexes for JSONB fields, and provide SQL commands to create them.

Quick Start

Use the postgres-expert skill to analyze and optimize the performance of the 'SELECT * FROM large_table WHERE json_data @> ''{"key": "value"}'' query.

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?

PostgreSQL query optimization analyzes slow-running SQL queries using EXPLAIN ANALYZE to identify performance bottlenecks. It evaluates execution plans to recommend and implement advanced indexing strategies like GIN, GiST, BRIN, partial, or expression indexes for specific data types and query patterns.

What is the best way to index JSONB data for fast retrieval in PostgreSQL?

Indexing JSONB data in PostgreSQL requires appropriate GIN indexes to optimize storage and retrieval operations. By analyzing query patterns, you can create targeted GIN indexes on JSONB fields to significantly accelerate complex JSON data filtering and containment queries.

How do I configure PgBouncer for PostgreSQL connection management?

Configuring PgBouncer for PostgreSQL connection management involves tuning max_connections to prevent connection exhaustion. Proper setup ensures efficient connection pooling, reduces database overhead, and maintains stable performance under high concurrent application load.

When do I need table partitioning for large PostgreSQL datasets?

Table partitioning for large PostgreSQL datasets is needed to improve query performance and manageability. Implementing partitioning divides large tables into smaller, more manageable pieces, allowing the query planner to scan fewer partitions and accelerate data retrieval.

Why does autovacuum tuning matter for PostgreSQL performance?

Autovacuum tuning matters for PostgreSQL performance because it combats table bloat and maintains operational efficiency. Optimizing autovacuum settings ensures dead tuples are reclaimed promptly, preventing transaction ID wraparound and sustaining consistent query execution speed.

Do I need advanced SQL knowledge to set up PostgreSQL replication and high availability?

Setting up PostgreSQL replication and high availability requires understanding of SQL, PostgreSQL internals, and database performance metrics. It provides insights into configuring and monitoring replication setups to ensure database high availability and fault tolerance.