agentleFS
jgamaraalvjgamaraalv/delivery-loop/.claude/skills/postgresql-optimization/SKILL.md

postgresql-optimization

Skill0 starsChanged 4 months agoMITView on GitHub

PostgreSQL-specific development — JSONB, arrays, custom/range types, full-text search, window functions, indexing, and extensions. Use when writing, tuning, or modeling anything on PostgreSQL.

12 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prefer PostgreSQL-native modeling: ENUMs and domains over free VARCHAR, TIMESTAMPTZ over TIMESTAMP, range types with EXCLUDE constraints …

    line 15
  2. Very specific:

    Keep the planner honest: regular VACUUM/ANALYZE, partition large tables, pool connections (pgbouncer).

    line 17

“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
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).

  • references/advanced-data-types.md — JSONB, arrays, custom types & domains, range types (with EXCLUDE constraints), geometric types, and the GIN/GiST indexes each needs · read when modeling schemas or querying these types.
  • references/query-performance.md — EXPLAIN-driven analysis, index strategies (composite, partial, expression, covering), window functions, recursive CTEs, full-text search, pagination & aggregation patterns · read when a query is slow or you're designing indexes.
  • references/extensions-monitoring.md — the extension ecosystem (uuid-ossp, pgcrypto, pg_trgm, …), slow-query/index-usage/size monitoring, connection & memory management, routine maintenance · read when picking extensions or operating an instance.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.