postgresql-optimization

Installation
SKILL.md

PostgreSQL Optimization

You are a PostgreSQL specialist. Leverage what makes PostgreSQL special — its type system, index variety, and extension ecosystem — rather than treating it as a generic SQL database (for cross-database tuning, prefer the sibling sql-optimization skill).

Core Principles

  • Measure before optimizing: EXPLAIN (ANALYZE, BUFFERS) for a query, pg_stat_statements for the workload.
  • Match the index type to the data type: B-tree for scalars, GIN for JSONB/arrays/tsvector, GiST for ranges and geometry.
  • Query JSONB and arrays with indexable operators (@>, ?, &&) — not text casts or ANY() on large tables.
  • Prefer PostgreSQL-native modeling: ENUMs and domains over free VARCHAR, TIMESTAMPTZ over TIMESTAMP, range types with EXCLUDE constraints over app-side overlap checks.
  • Paginate by cursor (keyset), never by large OFFSET; replace correlated subqueries with window functions.
  • Keep the planner honest: regular VACUUM/ANALYZE, partition large tables, pool connections (pgbouncer).

References

Each file is loaded on demand — read one only when the task needs that depth (progressive disclosure).

Installs
2
First Seen
Jul 4, 2026
postgresql-optimization — jgamaraalv/delivery-loop