analyze-db-performance

analyze-db-performance is a command for coding agents from sgaunet/claude-plugins. It costs 14 tokens per session (1,666 once invoked), scanned A, original, MIT.

A command that examines the performance of a PostgreSQL database, a database system used to store application data.

In plain words
What is it for?
Use it with a database connection, a slow-query log, or local logs to identify slow queries, large tables, and index-usage patterns.
Why use it?
It brings together slow-query, table-size, index-use, and system information so performance problems are easier to locate.

Command

Part of the devops-infrastructure plugin — 1 command, 5 agents shipped together

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 commands/sgaunet/claude-plugins/analyze-db-performance
Clone the repo
git clone --depth 1 https://github.com/sgaunet/claude-plugins

Or install devops-infrastructure, the plugin that ships this one along with the rest of its 1 command, 5 agents.

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 analyze-db-performance

README.md
[![agentmods](https://agentmods.dev/badge/commands/sgaunet/claude-plugins/analyze-db-performance.svg)](https://agentmods.dev/commands/sgaunet/claude-plugins/analyze-db-performance)
Your own site
<a href="https://agentmods.dev/commands/sgaunet/claude-plugins/analyze-db-performance"><img src="https://agentmods.dev/badge/commands/sgaunet/claude-plugins/analyze-db-performance.svg" alt="Measured on agentmods" height="20"></a>
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,666 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.00014 $0.01666
Opus 5 $0.00007 $0.00833
Sonnet 5 $0.00003 $0.00333
Haiku 4.5 $0.00001 $0.00167

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

Security

Grade A, and why

analyze-db-performance 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.

plugins/devops-infrastructure/commands/analyze-db-performance.md · 190 lines

How it starts

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

Analyze Database Performance Command

Analyze PostgreSQL database performance using pg_stat_statements, slow query logs, and system metrics.

Process

  1. Validate Input: Check if argument is:

    • Database connection string (postgres://...)
    • Path to slow query log file
    • None (will look for local log files)
  2. Gather Performance Data: Launch 3 parallel Haiku agents to collect database metrics concurrently:

    Agent #1: Slow Query Analyzer

    • If connection string: Execute query against pg_stat_statements
      SELECT query, calls, total_exec_time, mean_exec_time, max_exec_time
      FROM pg_stat_statements
      ORDER BY mean_exec_time DESC
      LIMIT 20;
      
    • If log file: Parse slow query log and extract patterns
    • Return: list of top 20 slowest queries with execution stats

    Agent #2: Table Size Analyzer

    • If connection string: Execute table size query
      SELECT schemaname, tablename,
             pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))
      FROM pg_tables
      ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;
      
    • Return: list of tables sorted by size

    Agent #3: Index Usage Analyzer

    • If connection string: Execute index usage query
      SELECT schemaname, tablename, indexname, idx_scan
      FROM pg_stat_user_indexes
      WHERE idx_scan = 0
      ORDER BY pg_relation_size(indexrelid) DESC;
      
    • Return: list of unused indexes (candidates for removal)
  3. Launch 2 parallel Sonnet agents to analyze performance data:

    Agent #4: PostgreSQL Specialist (postgresql-specialist agent)

    • Analyze slow queries from Agent #1
    • Review table sizes from Agent #2
    • Evaluate index usage from Agent #3
    • Generate optimization recommendations specific to PostgreSQL
    • Return: PostgreSQL-specific findings (indexes, query rewrites, config tuning)

    Agent #5: General Database Specialist (database-specialist agent)

    • Perform cross-platform analysis of performance patterns
    • Identify anti-patterns (N+1 queries, missing indexes, bloat)
    • Suggest architectural improvements
    • Return: general database optimization recommendations

Read the full file on GitHub · 190 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 · 190 lines · 14 tokens per session scan A a780c3bd134e

Subscribe to this mod's changes

analyze-db-performance is a command published in the GitHub repository sgaunet/claude-plugins (16 stars, last pushed 2d ago), licensed MIT. It adds 14 tokens to every session and 1,666 once invoked, about $0.0001 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.