Skip to main content
Glama

explain_query

Understand why a Postgres query is slow by reading its plan in plain language. Get estimates without executing, and identify costly steps.

Instructions

EXPLAIN a query (by literal SQL or by pg_stat_statements queryid) and read the plan in plain language.

Estimates only: without analyze this never executes the query, and the reading says what is expensive and why — it is NOT a recommendation. 'analyze' actually runs the query (SELECT-only, gated per profile by allow_analyze; refused on profiles that do not opt in). For parameterized queries pass 'params' with representative values — skewed values often change the plan entirely.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlNo
paramsNo
analyzeNo
profileYes
queryidNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

With no annotations, the description fully carries the burden of behavioral disclosure. It explicitly states that without analyze the query is never executed, that analyze actually runs the query but only as SELECT-only and only on profiles that opt in, and that the output is not a recommendation. This is exemplary transparency.

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

Conciseness5/5

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

The description is four sentences long, front-loaded with the main purpose, and each sentence adds distinct value. It avoids redundancy, making every line earn its place.

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

Completeness4/5

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

The description is highly complete given the output schema exists, covering purpose, behavior, safety, and parameter semantics. The only minor gap is that it does not explicitly state that sql and queryid are mutually exclusive or that at least one must be provided, which could cause confusion for an agent constructing a call.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate. It does so thoroughly: sql and queryid are explained as the two lookup methods, params are described as representative values for parameterized queries, analyze is explained as the execution toggle, and profile is contextualized via per-profile allow_analyze gating. This fully compensates for the empty schema.

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?

The description opens with a precise verb and resource: 'EXPLAIN a query (by literal SQL or by pg_stat_statements queryid) and read the plan in plain language.' It clearly states the tool's function and its two input modes, distinguishing it from the sibling tools (list_profiles, list_hotspots, find_dead_weight) which serve different purposes.

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?

The description provides clear context for when to use estimate mode versus analyze mode, explains that analyze is gated per profile, and advises passing params for parameterized queries. It does not explicitly name alternative tools, but the guidance for using this tool effectively is strong, leaving no ambiguity about its intended use.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Svaca33/pgverdict'

If you have feedback or need assistance with the MCP directory API, please join our Discord server