Skip to main content
Glama
isdaniel

PostgreSQL-Performance-Tuner-Mcp

get_slow_queries

Read-onlyIdempotent

Identify and analyze slow PostgreSQL queries using pg_stat_statements to optimize database performance by revealing top time-consuming queries with execution metrics.

Instructions

Retrieve slow queries from PostgreSQL using pg_stat_statements.

Returns the top N slowest queries ordered by total execution time. Requires the pg_stat_statements extension to be enabled.

Note: This tool focuses on user/application queries only. System catalog queries (pg_catalog, information_schema, pg_toast) are automatically excluded.

The results include:

  • Query text (normalized)

  • Total execution time

  • Number of calls

  • Mean execution time

  • Rows returned

  • Shared buffer hits/reads for cache analysis

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of slow queries to return (default: 10)
min_callsNoMinimum number of calls for a query to be included (default: 1)
min_total_time_msNoMinimum total execution time in milliseconds (default: 0)
order_byNoColumn to order results bytotal_time
Behavior4/5

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

The description adds valuable behavioral context beyond what annotations provide. While annotations declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, the description adds that it 'Requires the pg_stat_statements extension to be enabled' and specifies what types of queries are excluded (system catalog queries). It also details the specific metrics returned, providing important operational context.

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 and front-loaded with the core purpose, followed by prerequisites, scope limitations, and detailed output information. Every sentence adds value without redundancy. The bulleted list of returned metrics is particularly efficient for conveying complex information clearly.

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 read-only analysis tool with good annotations but no output schema, the description provides comprehensive context about what the tool does, prerequisites, scope limitations, and detailed output format. The main gap is the lack of output schema, but the description compensates well by explicitly listing all returned metrics with their semantic meaning.

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?

With 100% schema description coverage, the input schema already fully documents all 4 parameters with descriptions, defaults, and constraints. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation but doesn't provide additional semantic context about how parameters interact or affect results.

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's purpose: 'Retrieve slow queries from PostgreSQL using pg_stat_statements' with specific details about what it returns ('top N slowest queries ordered by total execution time'). It distinguishes from siblings like 'get_active_queries' by focusing on historical performance data rather than currently running queries.

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 provides clear context for when to use this tool: analyzing slow queries with pg_stat_statements enabled, focusing on user/application queries while excluding system catalog queries. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools for different performance analysis needs.

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/isdaniel/pgtuner-mcp'

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