Skip to main content
Glama

slow_query_rca

Read-only

Diagnose root cause and actions for the top pg_stat_statements entry by total execution time. Pass statements for offline analysis or omit to pull live.

Instructions

[READ] RCA for the worst pg_stat_statements entry, with cause + action.

Picks the statement with the greatest total execution time and maps its
numbers (mean time, cache-hit ratio, temp spill, calls) — plus an optional
EXPLAIN plan — to cited causes and concrete actions. Pass 'statements' for
pure/offline analysis, or omit to pull the top statements live.

Args:
    statements: Injected pg_stat_statements rows (as from top_queries); if
        omitted, the worst statements are pulled live.
    explain_sql: Optional SQL to EXPLAIN so plan node types feed the RCA.
    limit: How many statements to pull when not injected (default 20).
    target: Target name from config; omit for the default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
targetNo
statementsNo
explain_sqlNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

readOnlyHint=true already declares this a safe read, and the description adds real value beyond that: it pulls live top statements by default when no rows are injected and optionally runs an EXPLAIN so plan node types feed the analysis. It doesn't discuss permissions or the exact shape of the emitted causes/actions, but the behavioral flow is well disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the [READ] tag and core purpose, then explains modes, then consolidates parameters in an Args block. It is slightly long with a bulleted list, but each sentence contributes needed information with no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a four-parameter read-only analysis tool with no output schema, the description covers what is analyzed, the selection criterion, the live-vs-injected modes, the optional EXPLAIN enrichment, and the nature of the output (cited causes + concrete actions). Nothing an agent needs to call it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the full burden and documents all four parameters: statements (injected rows, sourced from top_queries), explain_sql (optional SQL to EXPLAIN), limit (count pulled when not injected, default 20), and target (config name, omit for default). Coverage is complete, though definitions stay at a summary level.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: root-cause analysis of the worst pg_stat_statements entry. It specifies the exact selection rule (greatest total execution time) and the transformation performed (numbers mapped to cited causes and concrete actions), which distinguishes it from siblings like top_queries (listing) and explain_query (raw plan).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Clearly explains the two operating modes: pass 'statements' for offline analysis or omit to pull top statements live, and references top_queries as the source of injectable rows. It gives actionable context but names no explicit alternative RCA/diagnostic sibling or when-not conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.