Agent skill

Postgres Optimization

by rohitg00 in rohitg00/awesome-claude-code-toolkit

PostgreSQL optimization including indexes, query plans, partitioning, JSONB operations, and connection pooling

Apache-2.0Auto-check passedDatabases

Install Postgres Optimization

skills CLI
$ npx skills add rohitg00/awesome-claude-code-toolkit --skill postgres-optimization -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rohitg00/awesome-claude-code-toolkit postgres-optimization --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rohitg00/awesome-claude-code-toolkit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/postgres-optimization .claude/skills/postgres-optimization && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
postgres-optimization
GitHub stars
2.7k
Token cost
~1.1k tokens
SKILL.md length
214 words
Files
1
Skills in repo
37
Repo updated
First seen
Licence
Apache-2.0

At a glance

PostgreSQL optimization including indexes, query plans, partitioning, JSONB operations, and connection pooling

  • Tasks that involve Query optimization
  • SKILL.md covers Index Strategies, Reading Query Plans, Partitioning and JSONB Operations, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Tasks that involve Database administration

What it does

Postgres Optimization is an agent skill from rohitg00/awesome-claude-code-toolkit. PostgreSQL optimization including indexes, query plans, partitioning, JSONB operations, and connection pooling

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Query optimization and Database administration. It works with PostgreSQL. The repository describes itself as: The most comprehensive toolkit for Claude Code -- 135 agents, 35 curated skills, 42 commands, 176+ plugins, 20 hooks, 15 rules, 7 templates, 14 MCP configs, 26 companion apps, 52… The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Query optimization
  • Tasks that involve Database administration

Example prompts

  • “/postgres-optimization”

What it can do on your machine

Read from SKILL.md and the folder at commit ebdf1d5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql and ini).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Postgres Optimization loads about 1.1k tokens when it runs. Until then it costs about 33 tokens; SKILL.md has 214 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~33
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rohitg00/awesome-claude-code-toolkit at commit ebdf1d5, republished under its Apache-2.0 licence (© rohitg00). 214 words, ~1,122 tokens.

Download SKILL.mdSave it as .claude/skills/postgres-optimization/SKILL.md (or your agent's skills folder).
name
postgres-optimization
description
PostgreSQL optimization including indexes, query plans, partitioning, JSONB operations, and connection pooling

PostgreSQL Optimization

Index Strategies

sql
-- B-tree index for equality and range queries (default)
CREATE INDEX idx_orders_customer_id ON orders (customer_id);

-- Composite index (column order matters: equality columns first, range last)
CREATE INDEX idx_orders_status_created ON orders (status, created_at DESC);

-- Partial index (smaller, faster for filtered queries)
CREATE INDEX idx_orders_pending ON orders (created_at)
  WHERE status = 'pending';

-- Covering index (avoids table lookup entirely)
CREATE INDEX idx_users_email_name ON users (email) INCLUDE (name, avatar_url);

-- GIN index for JSONB containment queries
CREATE INDEX idx_products_metadata ON products USING GIN (metadata);

-- GiST index for full-text search
CREATE INDEX idx_articles_search ON articles USING GiST (
  to_tsvector('english', title || ' ' || body)
);

-- Concurrent index creation (no table lock)
CREATE INDEX CONCURRENTLY idx_large_table_col ON large_table (col);

Reading Query Plans

sql
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT o.id, o.total, u.name
FROM orders o
JOIN users u ON o.user_id = u.id
WHERE o.status = 'shipped'
  AND o.created_at > NOW() - INTERVAL '30 days'
ORDER BY o.created_at DESC
LIMIT 20;

Key things to look for in the plan:

  • Seq Scan on large tables indicates a missing index
  • Nested Loop with high row estimates suggests missing join index
  • Sort without Index Scan means the sort is happening in memory/disk
  • Buffers: shared hit vs shared read shows cache efficiency

Partitioning

sql
CREATE TABLE events (
    id          BIGINT GENERATED ALWAYS AS IDENTITY,
    event_type  TEXT NOT NULL,
    payload     JSONB NOT NULL,
    created_at  TIMESTAMPTZ NOT NULL DEFAULT NOW()
) PARTITION BY RANGE (created_at);

CREATE TABLE events_2024_q1 PARTITION OF events
    FOR VALUES FROM ('2024-01-01') TO ('2024-04-01');
CREATE TABLE events_2024_q2 PARTITION OF events
    FOR VALUES FROM ('2024-04-01') TO ('2024-07-01');

-- Index on each partition (inherited automatically in PG 11+)
CREATE INDEX ON events (created_at, event_type);

Partition tables with more than 10M rows when queries consistently filter on the partition key.

JSONB Operations

sql
-- Query nested JSONB fields
SELECT * FROM products
WHERE metadata @> '{"category": "electronics"}'
  AND (metadata ->> 'price')::numeric < 500;

-- Update nested JSONB
UPDATE products
SET metadata = jsonb_set(metadata, '{stock}', to_jsonb(stock - 1))
WHERE id = 'abc';

-- Aggregate JSONB arrays
SELECT id, jsonb_array_elements_text(metadata -> 'tags') AS tag
FROM products
WHERE metadata ? 'tags';

Connection Pooling

ini
# pgbouncer.ini
[databases]
app = host=localhost port=5432 dbname=app

[pgbouncer]
pool_mode = transaction
max_client_conn = 1000
default_pool_size = 25
min_pool_size = 5
reserve_pool_size = 5
server_idle_timeout = 300

Use transaction-level pooling for web applications. Session-level pooling for apps that use prepared statements or temp tables.

Common Tuning Parameters

sql
-- Check for slow queries
SELECT query, calls, mean_exec_time, total_exec_time
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 10;

-- Find unused indexes
SELECT indexrelname, idx_scan, pg_size_pretty(pg_relation_size(indexrelid))
FROM pg_stat_user_indexes
WHERE idx_scan = 0
ORDER BY pg_relation_size(indexrelid) DESC;

Anti-Patterns

  • Creating indexes on every column instead of analyzing actual query patterns
  • Using SELECT * when only a few columns are needed
  • Not using EXPLAIN ANALYZE to verify index usage
  • Storing large blobs in JSONB when a separate table with proper types is better
  • Missing connection pooling (each connection uses ~10MB of server memory)
  • Running VACUUM FULL during peak hours (locks the entire table)

Checklist

  • Indexes match actual query patterns (check pg_stat_statements)
  • Composite indexes ordered: equality, then sort, then range columns
  • EXPLAIN ANALYZE run on all critical queries
  • Partial indexes used for frequently filtered subsets
  • Connection pooler (PgBouncer/pgcat) in front of PostgreSQL
  • Table partitioning considered for tables over 10M rows
  • Unused indexes identified and dropped
  • pg_stat_statements enabled for query performance monitoring

© rohitg00, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/postgres-optimization of rohitg00/awesome-claude-code-toolkit.

Open the folder on GitHubat commit ebdf1d5

Compare with similar skills

Postgres Optimization next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Postgres Optimization compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Postgres Optimization this skillrohitg00/awesome-claude-code-toolkit2.7k—~1.1kAutomated safety check: PassApache-2.0
Postgres Expertcin12211/orca-q223—~5.5kAutomated safety check: PassMIT
Postgres ExpertRightNow-AI/openfang18k—~830Automated safety check: PassApache-2.0
DB Ops SopOpenDCAI/DataMind406—~388Automated safety check: PassApache-2.0
PostgreSQL ProJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
PlanetScale Postgres Playbookplanetscale/database-skills6983 repos~1.8kAutomated safety check: PassMIT

Similar skills

  • Postgres Expert

    cin12211/orca-q

    PostgreSQL query optimization, JSONB operations, advanced indexing strategies, partitioning, connection management, and database administration.

    223 GitHub stars~5.5k tokensUpdated 16 days ago
    DatabasesAuto-check passed
  • Postgres Expert

    RightNow-AI/openfang

    PostgreSQL expert for query optimization, indexing, extensions, and database administration

    18k GitHub stars~830 tokensUpdated 3 mo ago
    DatabasesAuto-check passed
  • DB Ops Sop

    OpenDCAI/DataMind

    Database operations runbook — backup, recovery, performance tuning, troubleshooting.

    406 GitHub stars~388 tokensUpdated 17 days ago
    DatabasesAuto-check passed
  • PostgreSQL Pro

    Jeffallan/claude-skills

    Tunes and administers PostgreSQL: EXPLAIN-driven query tuning, index choice, JSONB, extensions, streaming or logical replication, VACUUM and pg_stat monitoring.

    12k GitHub stars~1.5k tokensUpdated 4 days ago
    DatabasesAuto-check passed
  • PlanetScale Postgres Playbook

    planetscale/database-skills

    Official

    Indexes reference files on Postgres schema design, indexing, partitioning, query patterns, MVCC and VACUUM, and PlanetScale-specific operations.

    698 GitHub starsUsed in 3 repos~1.8k tokens
    DatabasesAuto-check passed
  • PostgreSQL Documentation Reference

    2025Emma/vibe-coding-cn

    PostgreSQL database documentation - SQL queries, database design, administration, performance tuning, and advanced features. Use when working with PostgreSQL…

    23k GitHub starsUsed in 1 repo~19k tokens
    DatabasesAuto-check passed

More from rohitg00/awesome-claude-code-toolkit

All 37 skills in this repo
  • Accessibility Wcag

    rohitg00/awesome-claude-code-toolkit

    Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing

    2.7k GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed
  • API Design Patterns

    rohitg00/awesome-claude-code-toolkit

    REST API design with resource naming, pagination, versioning, and OpenAPI spec generation

    2.7k GitHub stars~1.2k tokensUpdated 4 mo ago
    Auto-check passed
  • Authentication Patterns

    rohitg00/awesome-claude-code-toolkit

    Authentication and authorization patterns including OAuth2, JWT, RBAC, session management, and PKCE flows

    2.7k GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed
  • AWS Cloud Patterns

    rohitg00/awesome-claude-code-toolkit

    AWS cloud patterns for Lambda, ECS, S3, DynamoDB, and Infrastructure as Code with CDK/Terraform

    2.7k GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • CI CD Pipelines

    rohitg00/awesome-claude-code-toolkit

    CI/CD pipeline patterns for GitHub Actions, GitLab CI, testing strategies, and deployment automation

    2.7k GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Continuous Learning

    rohitg00/awesome-claude-code-toolkit

    Auto-extract patterns from coding sessions, track corrections, and build reusable knowledge with confidence scoring

    2.7k GitHub stars~1.4k tokensUpdated 4 mo ago
    Auto-check passed

Works with

Categories

Questions about Postgres Optimization

What does Postgres Optimization do?

PostgreSQL optimization including indexes, query plans, partitioning, JSONB operations, and connection pooling. Postgres Optimization is an agent skill from rohitg00/awesome-claude-code-toolkit.

When should I use Postgres Optimization?

Postgres Optimization fits situations like: tasks that involve Query optimization; tasks that involve Database administration.

How do I install Postgres Optimization in Claude Code?

Run `npx skills add rohitg00/awesome-claude-code-toolkit --skill postgres-optimization -a claude-code`. Or copy the skill folder (skills/postgres-optimization in rohitg00/awesome-claude-code-toolkit) into .claude/skills/postgres-optimization in your project. Claude Code loads it when a task matches its description.

How do I install Postgres Optimization in Codex?

Run `npx skills add rohitg00/awesome-claude-code-toolkit --skill postgres-optimization -a codex`. Or copy the skill folder (skills/postgres-optimization in rohitg00/awesome-claude-code-toolkit) into .agents/skills/postgres-optimization in your project. Codex loads it when a task matches its description.

Can I use Postgres Optimization in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rohitg00/awesome-claude-code-toolkit --skill postgres-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/postgres-optimization, .gemini/skills/postgres-optimization, .github/skills/postgres-optimization and .opencode/skills/postgres-optimization in your project.

What does Postgres Optimization need to run?

SKILL.md names no scripts, command-line tools or credentials: Postgres Optimization is instructions for the agent only.

Does Postgres Optimization access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Postgres Optimization safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Postgres Optimization use?

Postgres Optimization is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Postgres Optimization use?

About 1.1k tokens (SKILL.md is roughly 4.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Postgres Optimization?

Skills that share tags, products or a category with Postgres Optimization: Postgres Expert (cin12211/orca-q, 223 stars), Postgres Expert (RightNow-AI/openfang, 18k stars), DB Ops Sop (OpenDCAI/DataMind, 406 stars) and PostgreSQL Pro (Jeffallan/claude-skills, 12k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Postgres Optimization?

rohitg00 (a GitHub user) maintains it in rohitg00/awesome-claude-code-toolkit, which has 2,683 GitHub stars. The repository holds 37 skills in this directory. The repository was last updated on May 12, 2026.

Source: rohitg00/awesome-claude-code-toolkit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.