postgresql-indexing

postgresql-indexing is a skill for Claude Code, Codex from prowler-cloud/prowler. It costs 108 tokens per session (3,429 once invoked), scanned A, original, Apache-2.0.

A guide to adding and checking indexes in PostgreSQL, the database system used to store application data. Indexes are extra data structures that can help the database find rows faster.

In plain words
What is it for?
It helps developers design indexes, optimize queries, work with partitioned tables, and safely create, remove, rebuild, or validate indexes.
Why use it?
It helps avoid slow queries, wasted storage, blocked production tables, and indexes that the database cannot use effectively. It also covers checking changes with EXPLAIN ANALYZE and maintaining tables afterward.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/prowler-cloud/prowler/postgresql-indexing
Any agent
npx skills add prowler-cloud/prowler --skill postgresql-indexing
Clone the repo
git clone --depth 1 https://github.com/prowler-cloud/prowler

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for postgresql-indexing

README.md
[![agentmods](https://agentmods.dev/badge/skills/prowler-cloud/prowler/postgresql-indexing.svg)](https://agentmods.dev/skills/prowler-cloud/prowler/postgresql-indexing)
Your own site
<a href="https://agentmods.dev/skills/prowler-cloud/prowler/postgresql-indexing"><img src="https://agentmods.dev/badge/skills/prowler-cloud/prowler/postgresql-indexing.svg" alt="Measured on agentmods" height="20"></a>
Per session 108 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,429 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00108 $0.03429
Opus 5 $0.00054 $0.01715
Sonnet 5 $0.00022 $0.00686
Haiku 4.5 $0.00011 $0.00343

Measured 4d ago against content hash c3d4813593bf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

postgresql-indexing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/postgresql-indexing/SKILL.md · 394 lines

How it starts

The opening of the file, as written. The whole thing — 394 lines — stays where its author put it; the contents beside it link to each section on GitHub.

When to use

  • Creating or modifying PostgreSQL indexes
  • Analyzing query plans with EXPLAIN
  • Debugging slow queries or missing index usage
  • Dropping, reindexing, or validating indexes
  • Working with indexes on partitioned tables (findings, resource_finding_mappings)
  • Running VACUUM or ANALYZE after index changes

Index design

Partial indexes: constant columns go in WHERE, not in the key

When a column has a fixed value for the query (e.g., state = 'completed'), put it in the WHERE clause of the index, not in the indexed columns. Otherwise the planner cannot exploit the ordering of the other columns.

-- Bad: state in the key wastes space and breaks ordering
CREATE INDEX idx_scans_tenant_state ON scans (tenant_id, state, inserted_at DESC);

-- Good: state as a filter, planner uses tenant_id + inserted_at ordering
CREATE INDEX idx_scans_tenant_ins_completed ON scans (tenant_id, inserted_at DESC)
    WHERE state = 'completed';

Column order matters

Put high-selectivity columns first (columns that filter out the most rows). For composite indexes, the leftmost column must appear in the query's WHERE clause for the index to be used.

Validating index effectiveness

Always EXPLAIN (ANALYZE, BUFFERS) after adding indexes

Never assume an index is being used. Run EXPLAIN (ANALYZE, BUFFERS) to confirm.

EXPLAIN (ANALYZE, BUFFERS)
SELECT *
FROM users
WHERE email = '[email protected]';

Use Postgres EXPLAIN Visualizer (pev) to visualize query plans and identify bottlenecks.

Force index usage for testing

The planner may choose a sequential scan on small datasets. Toggle enable_seqscan = off to confirm the index path works, then re-enable it.

SET enable_seqscan = off;

EXPLAIN (ANALYZE, BUFFERS)
SELECT DISTINCT ON (provider_id) provider_id
FROM scans
WHERE tenant_id = '95383b24-da01-44b5-a713-0d9920d554db'
  AND state = 'completed'
ORDER BY provider_id, inserted_at DESC;

SET enable_seqscan = on;  -- always re-enable after testing

Read the full file on GitHub · 394 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 394 lines · 108 tokens per session scan A c3d4813593bf

Subscribe to this mod's changes

postgresql-indexing is a skill published in the GitHub repository prowler-cloud/prowler (14,748 stars, last pushed today), licensed Apache-2.0. It adds 108 tokens to every session and 3,429 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

cis-aws-database-3.11

Ensure to Regularly Review Security Configuration.

CyberStrikeus/CyberStrike · 17 tokens

amazon aurora dsql

Deprecated compatibility redirect for Aurora DSQL guidance. Use when a request concerns DSQL, Aurora DSQL, distributed SQL, DSQL schemas, migrations, queries, authentication, performance, or application development.

awslabs/mcp · 46 tokens

agent-squad-typescript

Use when building or modifying a Node.js / TypeScript app that uses the agent-squad npm package — multi-agent orchestration: orchestrator, agents (all built-in types + GroundedAgent), classifier routing (Bedrock / Anthropic / OpenAI), storage (in-memory / DynamoDB / SQL), retrievers (Amazon KB / Dakera), and tools…

2FastLabs/agent-squad · 87 tokens

dynamodb

AWS DynamoDB NoSQL database for scalable data storage. Use when designing table schemas, writing queries, configuring indexes, managing capacity, implementing single-table design, or troubleshooting performance issues.

itsmostafa/aws-agent-skills · 39 tokens

rds

AWS RDS relational database service for managed databases. Use when provisioning databases, configuring backups, managing replicas, troubleshooting connectivity, or optimizing performance.

itsmostafa/aws-agent-skills · 31 tokens

dsql

Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, foreign key…

awslabs/agent-plugins · 229 tokens