Skip to main content
Glama
Teja-sudo

postgres-mcp-server

by Teja-sudo

explain_query

Explain PostgreSQL query execution plans to identify performance bottlenecks and missing indexes. Optionally run with analyze for real timings.

Instructions

Show PostgreSQL's execution plan for a query. Use this to understand query performance and identify missing indexes. analyze=true runs the query to get actual timings (SELECT only). Optionally use server/database/schema params for one-time execution on a different server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to explain
analyzeNoExecute query for real timing (SELECT only, blocked for writes)
buffersNoInclude buffer/cache statistics
formatNoOutput formatjson
hypotheticalIndexesNoTest hypothetical indexes (requires hypopg extension)
serverNoOne-time server override. Execute on this server without changing main connection.
databaseNoOne-time database override. Uses this database for execution.
schemaNoOne-time schema override. Sets search_path for this execution only.
Behavior4/5

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

Since no annotations are provided, the description carries the full burden. It discloses behavioral traits: analyze executes the query for real timings (SELECT only, blocked for writes), hypothetical indexes require the hypopg extension, and server/database/schema are one-time overrides. It does not explicitly state that the tool is read-only, but the description implies safety.

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 concise: three sentences covering purpose, usage, and key parameters. Every sentence adds value without redundancy. It is well-structured and front-loaded with the main purpose.

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?

Given 8 parameters, no output schema, and many sibling tools, the description covers the essential aspects: purpose, key parameters, and behavioral notes. It could mention that the output is the execution plan itself, but that is implied. Overall, it is sufficiently complete for an agent to use the tool correctly.

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 coverage is 100% with descriptions for all parameters. The description adds significant meaning beyond the schema: it explains that analyze gives actual timings (SELECT only), buffers includes cache statistics, format outputs in various formats, hypothetical indexes need hypopg, and server/database/schema are for one-time execution. This enhances the agent's understanding.

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 clearly states the tool's purpose: 'Show PostgreSQL's execution plan for a query.' It specifies the action (show execution plan) and the resource (PostgreSQL query), and distinguishes its use case from sibling tools by mentioning performance analysis and missing indexes.

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 usage context: 'Use this to understand query performance and identify missing indexes.' It also gives specific guidance on the analyze parameter: 'analyze=true runs the query to get actual timings (SELECT only).' However, it does not explicitly contrast with sibling tools like analyze_query_indexes, which slightly reduces clarity.

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/Teja-sudo/postgres-mcp-server'

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