Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Explain SQL Query Plan

pg_explain
Read-only

Show the execution plan for a SQL query with EXPLAIN or EXPLAIN ANALYZE to analyze query performance. Get planned strategy or real execution stats including timing and row counts.

Instructions

Show the execution plan for a SQL query using EXPLAIN or EXPLAIN ANALYZE.

Use EXPLAIN to see the planned query strategy. Use EXPLAIN ANALYZE to actually execute the query and see real timing and row count statistics (costs real I/O).

Args:

  • sql: SQL query to explain (required, should be a SELECT)

  • analyze: Run EXPLAIN ANALYZE (executes the query, default: false)

  • buffers: Include buffer usage statistics — only with analyze:true (default: false)

  • format: Output format for the plan, 'text' or 'json' (default: text)

  • response_format: Response format

Returns: The query plan as text or JSON. Use 'json' format for programmatic parsing.

Warning: EXPLAIN ANALYZE actually executes the query, including any side effects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to explain
analyzeNoRun EXPLAIN ANALYZE (executes the query)
buffersNoInclude buffer stats (only with analyze: true)
formatNoPlan format: 'text' or 'json'text
response_formatNoOutput format: 'markdown' for human-readable, 'json' for machine-readablemarkdown
Behavior1/5

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

The description warns that EXPLAIN ANALYZE executes the query with potential side effects, contradicting the readOnlyHint: true annotation which asserts the tool is read-only. This is a critical inconsistency that undermines trust.

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 (about 10 lines) with clear sections (Args, Returns, Warning), front-loaded with the main purpose. Every sentence adds value, no fluff.

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?

Given the tool's moderate complexity and no output schema, the description covers all key aspects: parameters, return format, and a critical warning about side effects. It is complete for an agent to invoke the tool correctly.

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?

The description adds meaningful context beyond the schema, explaining the difference between sql and analyze, the dependency of buffers on analyze, and the format options. Schema coverage is 100%, so the baseline is 3, and the description provides extra clarity.

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 'Show the execution plan for a SQL query using EXPLAIN or EXPLAIN ANALYZE', which is a specific verb (show) and resource (execution plan). It distinguishes from siblings like pg_execute (which runs queries) by focusing on plan analysis.

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 explains when to use EXPLAIN vs EXPLAIN ANALYZE, providing clear context on the trade-offs (planned strategy vs real execution with I/O cost). However, it does not explicitly compare with sibling tools or state when not to use this tool.

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/foxter-io/mcp-postgresql'

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