Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
jeffallan avatar

Postgres Pro

  • 6.1k installs
  • 10.9k repo stars
  • Updated May 20, 2026
  • jeffallan/claude-skills

Structured PostgreSQL optimization guidance: EXPLAIN output interpretation, index selection and verification, query rewriting, replication setup, VACUUM tuning, and health monitoring.

About

PostgreSQL Pro is a specialist skill for senior database administration and performance optimization It guides developers through EXPLAIN ANALYZE workflows to identify bottlenecks design targeted indexes B-tree GIN GiST BRIN optimize slow queries and set up streaming or logical replication The skill covers JSONB storage strategies autovacuum tuning bloat monitoring via pg_stat views and replication lag tracking Key workflows include analyzing slow queries with pg_stat_statements creating concurrent indexes without locks verifying index usage before production deployment refreshing statistics after bulk changes and monitoring database health continuously Includes reference guides for performance JSONB extensions PostGIS pgvector pg_trgm replication and maintenance name postgres-pro description Use when optimizing PostgreSQL queries configuring replication or implementing advanced database features Invoke for EXPLAIN analysis JSONB operations extension usage VACUUM tuning performance monitoring license MIT metadata author https github com Jeffallan version 1 1 0 domain infrastructure triggers PostgreSQL Postgres EXPLAIN ANALYZE pg_stat JSONB streaming replication logical replication.

  • EXPLAIN (ANALYZE, BUFFERS) query analysis to identify Seq Scans, buffer hits, and nested loop bottlenecks
  • Index design and verification: B-tree, GIN, GiST, BRIN with pre/post EXPLAIN confirmation and concurrent creation
  • JSONB GIN indexing and containment queries for efficient JSON document filtering and extraction
  • VACUUM and autovacuum tuning with dead tuple monitoring and bloat detection via pg_stat_user_tables
  • Streaming and logical replication lag monitoring using pg_stat_replication and LSN tracking

Postgres Pro by the numbers

  • 6,080 all-time installs (skills.sh)
  • +203 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #21 of 911 Databases skills by installs in the Skillselion catalog
  • Security screen: HIGH risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

postgres-pro capabilities & compatibility

Capabilities
explain analyze interpretation and query optimiz · index design and verification (b tree, gin, gist · jsonb storage and gin indexing strategies · streaming and logical replication setup and moni · vacuum, analyze, and autovacuum tuning · pg_stat views for health monitoring and bloat de · performance baseline comparison and impact measu
Works with
postgres
Use cases
devops · refactoring
Platforms
macOS · Windows · Linux · WSL
Runs
Remote server
Pricing
Free
npx skills add https://github.com/jeffallan/claude-skills --skill postgres-pro

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs6.1k
repo stars10.9k
Security audit3 / 3 scanners passed
Last updatedMay 20, 2026
Repositoryjeffallan/claude-skills

What it does

Optimize PostgreSQL queries, configure replication, tune VACUUM, and monitor database health using EXPLAIN analysis and pg_stat views.

Who is it for?

Senior DBAs, backend engineers, SREs optimizing PostgreSQL workloads; teams running high-churn or complex analytical queries; applications requiring replication or advanced JSON storage.

Skip if: MySQL, MongoDB, or other database engines; schema design from scratch; application-level caching strategies; initial database setup (covered by general database skills).

When should I use this skill?

Query performance degrades, indexes need design or verification, replication lag appears, VACUUM tuning needed, JSONB queries are slow, or continuous monitoring required.

What you get

Developers can analyze slow queries with EXPLAIN, design and deploy verified indexes, implement replication, tune maintenance tasks, and proactively monitor database health.

  • EXPLAIN output with interpretation and bottleneck identification
  • Index definitions with rationale and pre/post verification
  • Configuration changes with before/after values

By the numbers

  • PostgreSQL versions supported: 12-16
  • Index types covered: 4 (B-tree, GIN, GiST, BRIN)
  • Replication modes: 2 (streaming, logical)

Files

SKILL.mdMarkdownGitHub ↗

PostgreSQL Pro

Senior PostgreSQL expert with deep expertise in database administration, performance optimization, and advanced PostgreSQL features.

When to Use This Skill

  • Analyzing and optimizing slow queries with EXPLAIN
  • Implementing JSONB storage and indexing strategies
  • Setting up streaming or logical replication
  • Configuring and using PostgreSQL extensions
  • Tuning VACUUM, ANALYZE, and autovacuum
  • Monitoring database health with pg_stat views
  • Designing indexes for optimal performance

Core Workflow

1. Analyze performance — Run EXPLAIN (ANALYZE, BUFFERS) to identify bottlenecks 2. Design indexes — Choose B-tree, GIN, GiST, or BRIN based on workload; verify with EXPLAIN before deploying 3. Optimize queries — Rewrite inefficient queries, run ANALYZE to refresh statistics 4. Setup replication — Streaming or logical based on requirements; monitor lag continuously 5. Monitor and maintain — Track VACUUM, bloat, and autovacuum via pg_stat views; verify improvements after each change

End-to-End Example: Slow Query → Fix → Verification

-- Step 1: Identify slow queries
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;

-- Step 2: Analyze a specific slow query
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT * FROM orders WHERE customer_id = 42 AND status = 'pending';
-- Look for: Seq Scan (bad on large tables), high Buffers hit, nested loops on large sets

-- Step 3: Create a targeted index
CREATE INDEX CONCURRENTLY idx_orders_customer_status
  ON orders (customer_id, status)
  WHERE status = 'pending';  -- partial index reduces size

-- Step 4: Verify the index is used
EXPLAIN (ANALYZE, BUFFERS)
SELECT * FROM orders WHERE customer_id = 42 AND status = 'pending';
-- Confirm: Index Scan on idx_orders_customer_status, lower actual time

-- Step 5: Update statistics if needed after bulk changes
ANALYZE orders;

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Performancereferences/performance.mdEXPLAIN ANALYZE, indexes, statistics, query tuning
JSONBreferences/jsonb.mdJSONB operators, indexing, GIN indexes, containment
Extensionsreferences/extensions.mdPostGIS, pg_trgm, pgvector, uuid-ossp, pg_stat_statements
Replicationreferences/replication.mdStreaming replication, logical replication, failover
Maintenancereferences/maintenance.mdVACUUM, ANALYZE, pg_stat views, monitoring, bloat

Common Patterns

JSONB — GIN Index and Query

-- Create GIN index for containment queries
CREATE INDEX idx_events_payload ON events USING GIN (payload);

-- Efficient JSONB containment query (uses GIN index)
SELECT * FROM events WHERE payload @> '{"type": "login", "success": true}';

-- Extract nested value
SELECT payload->>'user_id', payload->'meta'->>'ip'
FROM events
WHERE payload @> '{"type": "login"}';

VACUUM and Bloat Monitoring

-- Check tables with high dead tuple counts
SELECT relname, n_dead_tup, n_live_tup,
       round(n_dead_tup::numeric / NULLIF(n_live_tup + n_dead_tup, 0) * 100, 2) AS dead_pct,
       last_autovacuum
FROM pg_stat_user_tables
ORDER BY n_dead_tup DESC
LIMIT 20;

-- Manually vacuum a high-churn table and verify
VACUUM (ANALYZE, VERBOSE) orders;

Replication Lag Monitoring

-- On primary: check standby lag
SELECT client_addr, state, sent_lsn, write_lsn, flush_lsn, replay_lsn,
       (sent_lsn - replay_lsn) AS replication_lag_bytes
FROM pg_stat_replication;

Constraints

MUST DO

  • Use EXPLAIN (ANALYZE, BUFFERS) for query optimization
  • Verify indexes are actually used with EXPLAIN before and after creation
  • Use CREATE INDEX CONCURRENTLY to avoid table locks in production
  • Run ANALYZE after bulk data changes to refresh statistics
  • Monitor autovacuum; tune autovacuum_vacuum_scale_factor for high-churn tables
  • Use connection pooling (pgBouncer, pgPool)
  • Monitor replication lag via pg_stat_replication
  • Use prepared statements to prevent SQL injection
  • Use uuid type for UUIDs, not text

MUST NOT DO

  • Disable autovacuum globally
  • Create indexes without first analyzing query patterns
  • Use SELECT * in production queries
  • Ignore replication lag alerts
  • Skip VACUUM on high-churn tables
  • Store large BLOBs in the database (use object storage)
  • Deploy index changes without verifying the planner uses them

Output Templates

When implementing PostgreSQL solutions, provide: 1. Query with EXPLAIN (ANALYZE, BUFFERS) output and interpretation 2. Index definitions with rationale and pre/post verification 3. Configuration changes with before/after values 4. Monitoring queries for ongoing health checks 5. Brief explanation of performance impact

Knowledge Reference

PostgreSQL 12-16, EXPLAIN ANALYZE, B-tree/GIN/GiST/BRIN indexes, JSONB operators, streaming replication, logical replication, VACUUM/ANALYZE, pg_stat views, PostGIS, pgvector, pg_trgm, WAL archiving, PITR

Documentation

Related skills

How it compares

Use postgres-pro for extension SQL and performance stats; use ORM migration skills when changing application schema rather than server extensions.

FAQ

How do I diagnose why a query is slow?

Run EXPLAIN (ANALYZE, BUFFERS) on the query. Look for Seq Scans on large tables, high buffer hits, nested loops on large sets, and high actual execution times. Compare EXPLAIN output before and after index creation to verify the planner uses the index.

What index type should I use?

B-tree is default for equality and range queries; GIN for JSONB containment and full-text search; GiST for spatial and range types; BRIN for large sequential tables. Always verify with EXPLAIN before and after creation.

How do I prevent replication lag?

Monitor replication lag via pg_stat_replication LSN differences. Use streaming replication for near-real-time sync. Tune max_wal_senders, wal_keep_segments, and synchronous_commit based on RPO/RTO requirements. Alert on lag thresholds.

Is Postgres Pro safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Databasesdatabasespipelines

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.