Skip to content
Back to skills

Postgres Explain

ASecurity

Reads a PostgreSQL EXPLAIN ANALYZE plan, identifies where the time and rows go, and proposes index or query rewrites with the expected effect. Use when the user pastes a query plan, asks why a query is slow, or mentions sequential scans, nested loops, or missing indexes.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 18, 2026
ai-agentsgosqlnode

Security analysis

A100/100

Scanned November 18, 2026

npx -y skills add product-on-purpose/agent-skills-toolkit --skill postgres-explain --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Postgres Explain?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Postgres Explain
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/product-on-purpose-postgres-explain/badge)](https://www.skillsdirectory.com/skills/product-on-purpose-postgres-explain)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: "postgres-explain"
description: "Reads a PostgreSQL EXPLAIN ANALYZE plan, identifies where the time and rows go, and proposes index or query rewrites with the expected effect. Use when the user pastes a query plan, asks why a query is slow, or mentions sequential scans, nested loops, or missing indexes."
metadata:
  version: "0.1.0"
  tier: universal
  status: active
---

# postgres-explain

## Purpose

Explain a PostgreSQL `EXPLAIN (ANALYZE, BUFFERS)` plan in terms of where time goes, then propose the smallest change that removes the dominant cost.

## Procedure

1. If the user gave a query but no plan, ask them to run `EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)` and paste it. Warn that ANALYZE executes the query.
2. Find the node with the largest exclusive time (actual total time minus children). That is the target; ignore everything else until it is addressed.
3. Read the estimate-versus-actual rows on that node. A gap over 10x means stale statistics or a correlation the planner cannot see: propose `ANALYZE <table>` first, or extended statistics for correlated columns.
4. Match the node type to a remedy:
   - Seq Scan with a selective filter: an index on the filter columns, in filter order, with the most selective first.
   - Nested Loop with a large outer side: usually a missing index on the inner join key, or a bad row estimate on the outer side.
   - Hash Join spilling (Batches > 1): raise `work_mem` for the session, or reduce the hashed side.
   - Sort with external merge: an index matching the ORDER BY, or a smaller working set.
5. State the expected effect in the plan's own units ("this removes the 480 ms seq scan; expect under 5 ms with the index").

## Report

Lead with the one change to make. Then the evidence: the node, its time, its row estimate versus actual. Then the second-order options. Never propose more than three changes at once.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.