Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Why is this slow

why_is_this_slow
Read-only

Diagnose slow SQL queries by analyzing query plans, blocking, cache, and maintenance without executing the query. Get categorized suggestions for performance optimization.

Instructions

Diagnose why a SQL query might be slow, in one call. Runs EXPLAIN (FORMAT JSON) — does NOT execute the query — walks the plan tree, snapshots concurrent active queries + blocking lock pairs, reads the cluster-wide cache hit ratio, and produces categorised suggestions (plan / contention / cache / maintenance). Read-only; safe to run on a statement the agent doesn't want to materialise yet.

Example: why_is_this_slow(sql='SELECT * FROM orders WHERE customer_id = 42')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes
suggestionsYes
explain_planYes
plan_summaryYes
active_queriesYes
blocking_locksYes
cache_hit_ratioYes
Behavior5/5

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

The description discloses read-only behavior, non-execution of the query, and details the internal actions (EXPLAIN, plan walking, snapshotting locks, cache hit ratio). Annotations already indicate readOnlyHint=true, and the description adds significant behavioral context beyond that, with no contradictions.

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: two paragraphs, first explains functionality, second shows an example. Every sentence adds value, no fluff. It is well-structured and easy to read.

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 presence of an output schema (signal indicates yes) and annotations, the description covers the main functionality comprehensively: it lists the diagnostic components (plan, contention, cache, maintenance) and mentions the output is categorized suggestions. This is complete for the tool's purpose.

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

Parameters3/5

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

Schema description coverage is 50%: the 'sql' parameter has no description in the schema, and the description does not describe it either (only shows an example). The 'database' parameter is well-described in the schema. The description adds little beyond the example for the missing parameter, so it does not fully compensate for the low coverage.

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 diagnoses SQL query slowness in one call, specifying it runs EXPLAIN without executing, walks the plan tree, snapshots concurrent queries, and produces categorized suggestions. This distinguishes it from sibling tools like explain_query (which just runs EXPLAIN) and analyze_query_plan (which may focus on plan details).

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 explicitly says it is safe to run on a statement not yet materialized, implying use before execution. It gives an example. However, it does not explicitly state when not to use this tool or mention alternatives among siblings (e.g., when to use analyze_query_plan instead). The context is clear but lacks exclusions.

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/devopam/MCPg'

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