Skip to main content
Glama

query_performance

Identify slowest or most called queries by total time, calls, or IO using pg_stat_statements statistics. Filter by minimum call count and sort to pinpoint performance bottlenecks.

Instructions

Historical query stats - shows top queries by time/calls/IO from pg_stat_statements.

LEVEL: Database (database-wide query statistics)

USE FOR: "what queries are slowest?", finding high-frequency queries, cache hit analysis, queries using temp files, overall query patterns, "which queries consume most time?". DO NOT USE FOR: analyzing ONE specific query (use query_optimizer), live running queries (use database_health), index recommendations (use maintenance_analysis), query syntax validation (use analyze_query). REQUIRES: pg_stat_statements extension installed.

Examples: query_performance() - Top 20 queries by total time query_performance(order_by='calls') - Most frequently called queries query_performance(order_by='mean_time') - Slowest average execution query_performance(limit=50, min_calls=100) - Top 50, only queries called 100+ times

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of queries to return (1-500)
order_byNoSort by: total_time, calls, mean_time, rows, shared_blks_hit, shared_blks_readtotal_time
min_callsNoMinimum call count filter
urlNoDatabase URL for auto-connection

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

No annotations are present, so the description carries the full burden. It discloses that the tool provides historical stats from a specific source, implies it is read-only and non-destructive, and clarifies the database-wide scope. However, it does not explicitly state that it does not modify data or require certain permissions, which are minor gaps.

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 well-structured with clear sections (main sentence, LEVEL, USE FOR, DO NOT USE FOR, REQUIRES, examples). It is front-loaded with the core purpose, every sentence adds value, and there is no redundancy or extraneous text. Concise yet comprehensive.

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 (4 parameters, output schema exists), the description covers all necessary context: data source, scope, usage guidelines, prerequisites, and examples. The output schema handles return structure, so no need to describe it. The description is fully sufficient for an agent to use 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?

Schema description coverage is 100%, so baseline is 3. The description adds value by showing concrete examples of parameter usage (e.g., query_performance(order_by='calls'), query_performance(limit=50, min_calls=100)), illustrating how parameters combine meaningfully. This enhances understanding beyond the schema's individual descriptions.

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 it shows historical query stats from pg_stat_statements, with specific verb 'shows' and resource 'historical query stats'. It explicitly distinguishes from siblings like query_optimizer, database_health, maintenance_analysis, and analyze_query, making the purpose unambiguous.

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?

Provides explicit USE FOR and DO NOT USE FOR sections, listing specific alternatives for each non-use case (e.g., 'analyzing ONE specific query (use query_optimizer)'). Also states the prerequisite 'REQUIRES: pg_stat_statements extension installed.' This fully guides the agent on when and when not to invoke the 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/snss10/DBeast'

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