Skip to content
Agentmart
Submit a tool

pg-explain

Use when a Postgres query is slow or EXPLAIN shows a sequential scan, an endpoint is slow because of SQL, or you are adding a query against a large table.

Skill by Srimukh99

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/srimukh99-pg-explain

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use when a Postgres query is slow or EXPLAIN shows a sequential scan, an endpoint is slow because of SQL, or you are adding a query against a large table. Reads the plan and fixes the cause with measured before and after timings.

Use cases: backend, data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/pg-explain

What's inside

Skill name
pg-explain
Description
Use when a Postgres query is slow or EXPLAIN shows a sequential scan, an endpoint is slow because of SQL, or you are adding a query against a large table. Reads the plan and fixes the cause with measured before and after timings.
License
MIT
Instructions
29 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# pg-explain

## 1. Find the query

Use `pg_stat_statements` ordered by `total_exec_time` to find the top offenders, or take the query from the slow log or trace.

## 2. Get the real plan

`EXPLAIN (ANALYZE, BUFFERS) <query>;` on production-like data. `ANALYZE` executes the query, so wrap writes in `BEGIN; ... ROLLBACK;`.

## 3. Read it

| You see | Likely cause | Try |
| --- | --- | --- |
| Estimated rows far from actual (10x+) | Stale or missing statistics | `ANALYZE <table>`; extended statistics for correlated columns |
| Seq Scan on a big table with a selective filter | Missing or unusable index | Index on the filter columns; avoid functions on the column or add an expression index |
| Nested Loop with a large outer side | Bad estimate or missing join index | Fix stats; index the join key |
| Sort or Hash with `external merge` / disk | Not enough memory or no index for order | Index matching `ORDER BY`; raise `work_mem` for that query only |
| High `shared read` buffers | Data not cached, too much scanned | Narrow the query; covering index (`INCLUDE`) |

## 4. Choose the index type

B-tree for equality and ranges; GIN for JSONB, arrays and full-text; GiST for geometry and ranges; BRIN for huge append-only tables ordered by time. Partial indexes when queries always filter the same subset.

## 5. Prove it

Change one thing, re-run `EXPLAIN ANALYZE`, and report before and after execution time (`ship`). New indexes on live tables go through `pg-migrate`. Check that you're not duplicating an existing index; each one slows writes.

From Srimukh99/rubric, MIT.

More from Srimukh99/rubric

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Oct 4, 2026 (25 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from Srimukh99

Cite this page

pg-explain skill. Agent Mart. https://agentmart.dev/skills/srimukh99-pg-explain (last updated 2026-10-24)