postgres-pro

Optimizes PostgreSQL queries, indexes, replication, and maintenance using EXPLAIN analysis and pg_stat monitoring.

Updated Mar 9, 2026
One-click install
npx skills add https://github.com/ArMaTeC/Redball --skill postgres-pro-armatec
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: postgres-pro
Source: https://github.com/ArMaTeC/Redball/tree/main/.devin/skills/postgres-pro
Command: npx skills add https://github.com/ArMaTeC/Redball --skill postgres-pro-armatec

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Slow queries, table bloat, replication lag, and misconfigured autovacuum degrade PostgreSQL performance, and diagnosing them requires deep knowledge of EXPLAIN plans, index types, and pg_stat views. ## Core Features & Use Cases - Query Optimization: Analyze slow queries with EXPLAIN (ANALYZE, BUFFERS), design B-tree, GIN, GiST, or BRIN indexes, and verify planner behavior before and after changes. - JSONB and Extensions: Implement JSONB containment queries with GIN indexing, and configure extensions like PostGIS, pgvector, pg_trgm, pg_stat_statements, and timescaledb. - Replication and Maintenance: Set up streaming or logical replication, monitor lag via pg_stat_replication, tune autovacuum per table, and detect bloat. - Use Case: A dashboard query scans a 10M-row orders table sequentially. Use this Skill to identify the Seq Scan in EXPLAIN output, create a partial index with CREATE INDEX CONCURRENTLY, and verify the plan switches to an Index Scan. ## Quick Start Ask the assistant to analyze a slow PostgreSQL query with EXPLAIN ANALYZE and recommend an index with verification steps.

Frequently Asked Questions about postgres-pro

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

FAQPage Schema
How do I optimize a slow PostgreSQL query?▼

Run EXPLAIN (ANALYZE, BUFFERS) on the query to identify sequential scans, high buffer reads, or bad row estimates. Then create a targeted index with CREATE INDEX CONCURRENTLY, run ANALYZE to refresh statistics, and re-run EXPLAIN to verify the index is used.

What index type should I use in PostgreSQL?▼

Use B-tree for equality and range queries, GIN for JSONB containment and arrays, GiST for spatial data and ranges, and BRIN for large naturally ordered tables like time-series logs. Verify the choice with EXPLAIN before deploying to production.

How do I index JSONB columns in PostgreSQL?▼

Create a GIN index on the JSONB column for containment queries using the @> operator, or use jsonb_path_ops for a smaller index. For frequently filtered single keys, a B-tree expression index on data ->> 'key' is more selective.

Does PostgreSQL replication lag affect read replicas?▼

Yes, standby servers replay WAL asynchronously by default, so reads can return stale data. Monitor lag via pg_stat_replication on the primary and pg_last_xact_replay_timestamp on the standby, and use synchronous replication if freshness is required.

Why is my PostgreSQL table bloated and how do I fix it?▼

Bloat comes from dead tuples left by updates and deletes that autovacuum has not reclaimed. Check n_dead_tup in pg_stat_user_tables, tune autovacuum_vacuum_scale_factor for high-churn tables, and use pg_repack for online bloat removal without locking.

When should I not disable autovacuum in PostgreSQL?▼

Never disable autovacuum globally, since it prevents transaction ID wraparound and controls bloat. Instead, tune per-table settings like autovacuum_vacuum_scale_factor and cost delays to balance vacuum frequency against I/O impact.