Catalogue / postgres-deep
postgres-deep
MITSignedPostgreSQL deep-dive: EXPLAIN ANALYZE interpretation, index types (B-tree, GIN, GiST, BRIN), partial/covering/composite indexes, pg_stat_statements slow query analysis, Row Level Security, window functions, CTEs, advisory locks, LISTEN/NOTIFY, connection pooling with PgBouncer. Use when optimizing s…--- name: postgres-deep description: | PostgreSQL deep-dive: EXPLAIN ANALYZE interpretation, index types (B-tree, GIN, GiST, BRIN), partial/covering/composite indexes, pg_stat_statements slow query analysis, Row Level Security, window functions, CTEs, advisory locks, LISTEN/NOTIFY, connection pooling with PgBouncer. Use when optimizing slow queries, designing indexing strategy, implementing multi-tenancy. allowed-tools: Read, Grep, Glob ---
PostgreSQL Deep Dive
When to Use This Skill
- Optimizing slow queries with EXPLAIN ANALYZE
- Designing indexes for specific access patterns
- Implementing Row Level Security for multi-tenancy
- Using window functions for analytics queries
- Configuring PgBouncer for connection pooling
Core Principles
- EXPLAIN ANALYZE before optimizing — never guess; measure first; the plan shows the actual cost
- Index the access pattern, not the column — a composite index
(user_id, created_at DESC)beats two separate indexes for paginated user queries - Partial indexes reduce size and maintenance cost —
WHERE status = 'pending'on a 10M row table with 1000 pending rows = tiny, fast index - RLS is enforced at the DB layer — even if application code has a bug, unauthorized rows are invisible
- pg_stat_statements is your slow query log — enable it; it shows cumulative query costs across all calls
References available
references/query-optimization.md— EXPLAIN ANALYZE interpretation, node types, warning signs, stale statistics, work_mem, CTEsreferences/query-anti-patterns.md— N+1 queries, missing FK indexes, over-fetching, OFFSET pagination, NOT IN gotcha, DISTINCT misusereferences/indexing-strategies.md— B-tree, GIN, GiST, BRIN index types; composite and covering indexes; index type decision treereferences/index-tuning.md— partial indexes, expression indexes, index maintenance, unused/bloated index detection, CONCURRENTLYreferences/partitioning.md— range/list/hash partitioning, when to partition, partition pruning, partitioned table constraintsreferences/partition-management.md— partition maintenance, DETACH/DROP/ATTACH, pg_partman automation, anti-patternsreferences/connection-pooling.md— PgBouncer setup, pool modes (session/transaction/statement), pool sizing, application configreferences/connection-diagnostics.md— SHOW POOLS, pg_stat_activity monitoring, connection troubleshooting runbook, Kubernetes deploy
Scripts available
scripts/analyze-slow-queries.sh— query pg_stat_statements for top consumers and low cache-hit queries
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 2.6 kB | a3f856f3d3ed |
| SKILVAULT_SOURCE.json | 2.2 kB | a39977c2f2b1 |
| THIRD_PARTY_NOTICES.md | 2.1 kB | c2e125b5f806 |
| references/connection-diagnostics.md | 4.0 kB | 0a9f52ff5966 |
| references/connection-pooling.md | 4.6 kB | 457870deb278 |
| references/index-tuning.md | 4.2 kB | 1bdd236b62a0 |
| references/indexing-strategies.md | 3.6 kB | 6f3cfd52ee7c |
| references/partition-management.md | 3.6 kB | 40fd1fd2f055 |
| references/partitioning.md | 3.9 kB | 831765bbcc62 |
| references/query-anti-patterns.md | 5.3 kB | 5015d506a99f |
| references/query-optimization.md | 4.2 kB | 45bdb30502fc |
| scripts/analyze-slow-queries.sh | 7.6 kB | ca749a1ad5a5 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 0.1.0 Current | c5b74102c7fd | 29 Nov 2026 |
Locking a skill to one version needs Pro.