Skip to main content
Glama

get_top_queries

Read-only

Identify slow or resource-intensive queries by analyzing pg_stat_statements data. Sort by total time, mean time, or resource usage to pinpoint performance bottlenecks.

Instructions

Reports the slowest or most resource-intensive queries using data from the 'pg_stat_statements' extension.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of queries to return when ranking based on mean_time or total_time
sort_byNoRanking criteria: 'total_time' for total execution time or 'mean_time' for mean execution time per call, or 'resources' for resource-intensive queriesresources

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

Annotations already declare readOnlyHint=true, so the agent knows it's a safe read. The description adds context by specifying the data source (pg_stat_statements) which implies the extension must be enabled, but does not detail potential impacts like query reset or permission requirements.

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?

Single sentence, no unnecessary words. Clear and to the point. Could be slightly improved by adding a brief note about extension requirement, but remains appropriately sized.

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

Completeness3/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 and optional parameters, the description is adequate but minimal. It does not mention prerequisites (pg_stat_statements must be enabled) or any limitations, which would be helpful for an agent deciding whether to use this tool.

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 coverage is 100% with descriptions for both parameters. The overall description reinforces the sort_by options by mentioning 'slowest or most resource-intensive', but adds no new insight beyond what the schema provides.

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 uses a specific verb 'reports' and clearly identifies the resource as 'the slowest or most resource-intensive queries' from 'pg_stat_statements'. It distinguishes from siblings like analyze_query_indexes or explain_query by focusing on top queries by performance metrics.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives such as analyze_db_health or execute_sql. The description implies it's for identifying problematic queries but does not explicitly state when not to use it or direct to other tools.

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/crystaldba/postgres-mcp'

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