Skip to main content
Glama

get_top_queries

Read-only

Identify and rank a PostgreSQL database's slowest or most resource-intensive queries via pg_stat_statements data, enabling targeted performance tuning and index planning.

Instructions

Reports the slowest or most resource-intensive queries using data from the 'pg_stat_statements' extension. Only statements of the current database are reported.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "get_top_queries"
  }
}

Input Schema

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

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior4/5

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

Annotations already declare read-only, non-destructive, closed-world behavior, so the description's job is to add operational context — which it does by naming the required 'pg_stat_statements' extension and disclosing that only current-database statements appear. It does not say what happens if the extension is absent or whether statistics are cumulative since the last reset, which keeps it below a 5.

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?

Two tight sentences with the core purpose front-loaded and the scope caveat immediately after. No filler or redundant restatement of the title.

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?

For a simple two-parameter read-only tool with no output schema, the description covers purpose, data source, and scope adequately; return values need not be explained. Minor gaps are the absence of guidance on statistics accumulation and failure behavior when the extension is not installed.

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 100%, so both parameters (limit, sort_by) are already documented with enums and defaults. The description's phrase 'slowest or most resource-intensive' loosely maps onto the sort_by choices, but adds no syntax, format, or behavioral detail beyond the schema — baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb and resource ('Reports the slowest or most resource-intensive queries') and names the data source ('pg_stat_statements'). It is clear what the tool returns, though it does not explicitly contrast itself with siblings like explain_query or analyze_workload_indexes.

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?

There is no guidance on when to choose this tool over alternatives such as explain_query or analyze_workload_indexes, nor any prerequisite or exclusion stated. The only scoping note ('Only statements of the current database are reported') is a limitation, not usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.