pg-slow-query-diagnosis

pg-slow-query-diagnosis is a skill for Claude Code, Codex from isdaniel/pgtuner_mcp. It costs 52 tokens per session (3,128 once invoked), scanned A, original, Apache-2.0.

A guided process for finding why PostgreSQL database queries are slow by examining query statistics, execution plans, indexes, and table information.

In plain words
What is it for?
Use it to investigate slow queries, high latency, timeouts, resource-heavy database work, and possible index improvements.
Why use it?
It turns a broad performance problem into a structured investigation and produces specific optimization suggestions.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to investigate slow queries, high latency, timeouts, resource-heavy database work, and possible index improvements.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/isdaniel/pgtuner_mcp/pg-slow-query-diagnosis
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.

Any agent
npx skills add isdaniel/pgtuner_mcp --skill pg-slow-query-diagnosis
Clone the repo
git clone --depth 1 https://github.com/isdaniel/pgtuner_mcp

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 pg-slow-query-diagnosis

README.md
[![agentmods](https://agentmods.dev/badge/skills/isdaniel/pgtuner_mcp/pg-slow-query-diagnosis/github.svg)](https://agentmods.dev/skills/isdaniel/pgtuner_mcp/pg-slow-query-diagnosis)
Your own site
<a href="https://agentmods.dev/skills/isdaniel/pgtuner_mcp/pg-slow-query-diagnosis"><img src="https://agentmods.dev/badge/skills/isdaniel/pgtuner_mcp/pg-slow-query-diagnosis/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pg-slow-query-diagnosis

Your own site · 80×15
<a href="https://agentmods.dev/skills/isdaniel/pgtuner_mcp/pg-slow-query-diagnosis"><img src="https://agentmods.dev/badge/skills/isdaniel/pgtuner_mcp/pg-slow-query-diagnosis.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,128 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00052 $0.03128
Opus 5.5 $0.00021 $0.01251
Sonnet 5.5 $0.00010 $0.00626
Haiku 4.5 $0.00005 $0.00313

Measured 2mo ago against content hash 8ac3fbe307f1, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pg-slow-query-diagnosis 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 2mo 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/pg-slow-query-diagnosis/SKILL.md · 295 lines

How it starts

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

PostgreSQL Slow Query Diagnosis

This skill guides systematic diagnosis and optimization of slow queries in PostgreSQL databases using the pgtuner-mcp server tools.

When to Use This Skill

Use this skill when the user:

  • Reports slow queries or poor query performance
  • Asks "why is my query slow?" or "how can I speed up this query?"
  • Wants to find and fix the top resource-consuming queries
  • Mentions high query latency, timeouts, or slow API responses
  • Asks to investigate pg_stat_statements data

MCP Resources Available

Before calling tools, the agent can read lightweight resources for quick context:

  • pgtuner://docs/tools -- Full tool reference documentation
  • pgtuner://docs/workflows -- Recommended workflow patterns
  • pgtuner://query/{query_hash}/stats -- Detailed stats for a specific query by queryid (from get_slow_queries output)
  • pgtuner://table/{schema}/{table_name}/stats -- Quick table statistics without running the full tool
  • pgtuner://table/{schema}/{table_name}/indexes -- Indexes on a specific table

This skill corresponds to the diagnose_slow_queries MCP Prompt and partially to query_tuning. If the user triggers either prompt, follow this skill's workflow.

Prerequisites

  • The pgtuner-mcp server must be connected with a valid DATABASE_URI
  • Required: pg_stat_statements extension (check availability early -- if missing, tool will return an error)
  • Optional: hypopg extension for hypothetical index testing
  • Optional: pglast library on the server for SQL parsing in index recommendations

Pre-Flight Checks

Before starting the workflow, verify extension availability:

  • If get_slow_queries returns an error about pg_stat_statements, inform the user it must be enabled and provide setup instructions.
  • If the user wants hypothetical index testing, use manage_hypothetical_indexes with action: "check" to verify HypoPG is available. If not, skip Step 4 and rely on heuristic recommendations.

Read the full file on GitHub · 295 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. 2mo ago First seen · 295 lines · 52 tokens per session scan A 8ac3fbe307f1

Subscribe to this mod's changes

pg-slow-query-diagnosis is a skill published in the GitHub repository isdaniel/pgtuner_mcp (30 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 52 tokens to every session and 3,128 once invoked, about $0.0002 per session on Opus 5.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

pg-slow-query-diagnosis compared with skills from other repositories

pg-slow-query-diagnosis next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
pg-slow-query-diagnosisisdaniel/pgtuner_mcpSkill305mo agoApache-2.0A52Claude Code, Codex
exasol-mcp-serverexasol/mcp-serverSkill182d agoMITA36Claude Code, Codex
tencent-pg-slowquery-diagnosisTencentCloudCommunity/mcp-serverSkill323mo agoApache-2.0A75Claude Code, Codex
amazon aurora dsqlawslabs/mcpSkill9.9kyesterdayApache-2.0A46Claude Code
sql-optimizerMathews-Tom/armorySkill3405d agoMITA78Claude Code
profiling-slow-api-endpointsPostHog/posthogSkill41ktodaynoneA113Claude Code, Codex
ecto-constraint-debugoliver-kriska/claude-elixir-phoenixSkill574yesterdayMITA36Claude Code