Skip to main content
Glama
isdaniel

PostgreSQL-Performance-Tuner-Mcp

get_index_recommendations

Read-onlyIdempotent

Analyze PostgreSQL query workload to identify performance bottlenecks and generate optimal index recommendations that improve database performance.

Instructions

Get AI-powered index recommendations for your database.

Analyzes your query workload (from pg_stat_statements) and recommends indexes that would improve performance. Uses a sophisticated analysis algorithm that:

  1. Identifies slow queries and their access patterns

  2. Extracts columns used in WHERE, JOIN, ORDER BY, and GROUP BY clauses

  3. Generates candidate indexes (single-column and composite)

  4. If HypoPG is available, tests indexes without creating them

  5. Uses a greedy optimization algorithm to select the best index set

Note: This tool focuses on user/client tables only and excludes system catalog tables (pg_catalog, information_schema, pg_toast).

The recommendations consider:

  • Query frequency and total execution time

  • Estimated improvement from each index

  • Index size and maintenance overhead

  • Avoiding redundant indexes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workload_queriesNoOptional list of specific queries to analyze. If not provided, uses pg_stat_statements.
max_recommendationsNoMaximum number of index recommendations to return
min_improvement_percentNoMinimum improvement percentage for a recommendation to be included
include_hypothetical_testingNoWhether to test indexes using HypoPG (if available)
target_tablesNoOptional list of tables to focus on
Behavior4/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, and idempotentHint=true, indicating safe, non-destructive operations. The description adds valuable context beyond annotations: it explains the sophisticated 5-step algorithm, mentions HypoPG testing, and details what factors the recommendations consider (query frequency, improvement estimates, index size, avoiding redundancy).

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 description is well-structured with clear sections: purpose statement, algorithm breakdown, scope limitations, and recommendation factors. While comprehensive, it could be slightly more concise by combining some of the numbered algorithm steps into fewer sentences without losing clarity.

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?

Given the tool's complexity (sophisticated algorithm, 5 parameters) and rich annotations, the description provides substantial context about behavior, scope, and methodology. However, without an output schema, it doesn't describe the format or structure of the recommendations returned, which is a minor gap for a recommendation-generating 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?

With 100% schema description coverage, the input schema already documents all 5 parameters thoroughly. The description doesn't add significant parameter-specific information beyond what's in the schema, though it provides context about workload analysis and table focus that relates to parameters like 'workload_queries' and 'target_tables'.

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 'Get AI-powered index recommendations for your database' with specific details about analyzing query workload and recommending indexes to improve performance. It distinguishes from siblings like 'find_unused_indexes' or 'analyze_index_bloat' by focusing on generating new index recommendations rather than analyzing existing ones.

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 about when to use this tool: for analyzing query workload and getting index recommendations. It mentions exclusions (system catalog tables) but doesn't explicitly state when to use alternatives like 'explain_with_indexes' or 'manage_hypothetical_indexes' for specific scenarios.

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