postgres

Diagnose and optimize PostgreSQL performance, schema design, replication, and operations.

1|Updated Apr 26, 2026
One-click install
npx skills add https://github.com/CarlosPavajeau/light --skill postgres-carlospavajeau
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres
Source: https://github.com/CarlosPavajeau/light/tree/main/.claude/skills/postgres
Command: npx skills add https://github.com/CarlosPavajeau/light --skill postgres-carlospavajeau

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? PostgreSQL databases suffer from slow queries, bloated tables, connection exhaustion, and misconfigured replication, and diagnosing these issues requires deep operational knowledge scattered across many topics. ## Core Features & Use Cases - Query and Index Optimization: Identify unused, duplicate, and invalid indexes, fix N+1 patterns, and rewrite anti-patterns like OFFSET pagination into cursor-based queries. - Operations Guidance: Covers VACUUM/autovacuum tuning, XID wraparound prevention, WAL and checkpoint management, backup/PITR strategies, and replication failover. - PlanetScale Integration: Provides PgBouncer pooling configuration, pscale CLI commands, and query insights workflows for PlanetScale-hosted Postgres. - Use Case: When a table grows past 100GB and queries slow down, consult the partitioning and indexing references to plan range partitions, audit indexes, and verify improvements with EXPLAIN ANALYZE. ## Quick Start Ask the assistant to review your slow PostgreSQL query and suggest index and schema improvements using the postgres skill.

Frequently Asked Questions about postgres

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

FAQPage Schema
How do I find and remove unused indexes in PostgreSQL?

Query pg_stat_user_indexes joined with pg_index for indexes with idx_scan = 0, excluding unique and constraint-backing indexes. Always verify stats age and confirm with a human before dropping any index.

How do I fix slow PostgreSQL queries?

Start with EXPLAIN ANALYZE to confirm index usage, then check for anti-patterns like functions on indexed columns, OFFSET pagination, and N+1 loops. Add composite or partial indexes matching your WHERE and ORDER BY clauses.

When should I use PgBouncer instead of direct PostgreSQL connections?

Use PgBouncer on port 6432 for OLTP application workloads with high concurrency. Reserve direct connections on port 5432 for DDL, migrations, analytics, and session-dependent features like temp tables or LISTEN/NOTIFY.

What is XID wraparound in PostgreSQL and how do I prevent it?

XID wraparound occurs when 32-bit transaction IDs exhaust ~2 billion values, making old rows invisible. Prevent it by never disabling autovacuum, keeping transactions short, and alerting when age(datfrozenxid) exceeds 40-50% of the wraparound limit.

When should I partition a PostgreSQL table?

Partition general tables exceeding 100GB or 20M rows, and time-series or log tables exceeding 50GB or 10M rows. Partitioning mainly benefits maintenance and data retention rather than raw query speed.

Why does PostgreSQL run out of memory with high concurrency?

work_mem is allocated per operation, so memory usage multiplies across operations, parallel workers, and connections. Reduce work_mem globally, add connection pooling, and set statement_timeout to prevent OOM kills.