postgres

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

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/falentio/cimi --skill postgres-falentio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres
Source: https://github.com/falentio/cimi/tree/main/.agents/skills/skills/postgres
Command: npx skills add https://github.com/falentio/cimi --skill postgres-falentio

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 spread across many domains. ## Core Features & Use Cases - Query and Index Optimization: Detect unused, duplicate, and invalid indexes, rewrite SQL anti-patterns like N+1 queries and OFFSET pagination, and tune planner settings. - Operations and Architecture Guidance: Configure VACUUM/autovacuum, WAL archiving, checkpoints, memory allocation, connection pooling with PgBouncer, streaming replication, and backup/PITR strategies. - PlanetScale Integration: Use pscale CLI commands, query insights reports, and PlanetScale-specific connection pooling and extension guidance. - Use Case: When a production database shows rising latency, load this Skill to find slow queries via pg_stat_statements, audit indexes, check for long transactions blocking VACUUM, and apply targeted fixes. ## Quick Start Ask the assistant to review your PostgreSQL database for slow queries and unused indexes 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 unused indexes in PostgreSQL?

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

How to fix slow queries in PostgreSQL?

Enable pg_stat_statements to identify high mean_exec_time queries, then check for missing indexes, N+1 patterns, non-SARGable predicates, and OFFSET pagination. Use EXPLAIN ANALYZE to confirm index usage after changes.

When should I use PgBouncer connection pooling?

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

Why does PostgreSQL run out of connections or memory?

Each connection spawns an OS process consuming memory, and work_mem multiplies across operations, parallel workers, and connections. Fix this with connection pooling, lower work_mem, and statement_timeout rather than raising max_connections.

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; the partition key must be part of the primary key.

What is XID wraparound 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 800M to 1B.