Skip to main content
Glama
call518

MCP PostgreSQL Operations

get_pg_stat_statements_top_queries

Analyze top PostgreSQL queries by execution time to identify performance bottlenecks and optimize database performance using pg_stat_statements statistics.

Instructions

[Tool Purpose]: Analyze top queries that consumed the most time using pg_stat_statements extension

[Exact Functionality]:

  • Retrieve top query list based on total execution time

  • Display call count, average execution time, and cache hit rate for each query

  • Support identification of queries requiring performance optimization

[Required Use Cases]:

  • When user requests "slow queries", "performance analysis", "top queries", etc.

  • When database performance optimization is needed

  • When query performance monitoring or tuning is required

[Strictly Prohibited Use Cases]:

  • When pg_stat_statements extension is not installed

  • Requests for query execution or data modification

  • Requests for statistics data reset or configuration changes

Args: limit: Number of top queries to retrieve (default: 20, max: 100) database_name: Database name to analyze (uses default database if omitted)

Returns: Performance statistics including query text, call count, total execution time, average execution time, and cache hit rate

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
database_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing behavioral traits: it's a read-only analysis tool (implied by 'retrieve' and 'display'), requires pg_stat_statements extension, and specifies what data is returned. It doesn't mention rate limits or authentication requirements, but covers core functionality adequately.

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?

The structured format with clear sections ([Tool Purpose], [Exact Functionality], etc.) is well-organized and front-loaded. Some sections could be more concise (e.g., 'Required Use Cases' lists could be tighter), but overall it's efficiently structured with minimal waste.

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 complexity (performance analysis with prerequisites), no annotations, and an output schema exists, the description provides comprehensive context: purpose, functionality, use cases, prohibitions, parameter semantics, and return value explanation. It covers all necessary aspects for an agent to understand and 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 description coverage is 0%, so the description must compensate fully. It provides clear semantic meaning for both parameters: 'limit' specifies number of top queries with default and max values, 'database_name' explains it's optional and uses default if omitted. This adds substantial value beyond the bare 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 explicitly states the tool's purpose as analyzing top queries based on execution time using pg_stat_statements extension. It clearly distinguishes from siblings by focusing specifically on query performance analysis rather than general database monitoring, connections, or table statistics.

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

Usage Guidelines5/5

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

The description provides explicit 'Required Use Cases' (performance analysis, optimization requests) and 'Strictly Prohibited Use Cases' (when extension not installed, execution/modification requests). It clearly defines when to use this tool versus alternatives, including specific scenarios and 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/call518/MCP-PostgreSQL-Ops'

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