Skip to main content
Glama

analyze_workload_indexes

Read-onlyIdempotent

Recommends indexes for a Postgres workload by testing hypothetical candidates against pg_stat_statements queries, returning CREATE INDEX statements with estimated sizes and costs without creating them.

Instructions

Recommend indexes for this database's workload: the pg_stat_statements queries with at least 50 calls and 5 ms mean time, up to 100 by total time. Candidates are indexes on 1 to 3 columns that the queries filter, join, sort or group on, each tried as a hypothetical index (hypopg) and compared by planner cost. A greedy search adds one at a time while an addition lowers the workload cost by at least 10%, is worth its size and keeps the total within max_index_size_mb; it ends 30 seconds after the analysis starts, keeping what it has chosen by then. Nothing is created. Returns CREATE INDEX statements with estimated sizes and costs, skipped queries with reasons, and each query's cost before and after. Needs pg_stat_statements and hypopg. For queries you choose, use analyze_query_indexes.

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": "analyze_workload_indexes"
  }
}

Input Schema

NameRequiredDescriptionDefault
max_index_size_mbNoSize budget for all recommended indexes together, in MB (default 10000); a candidate that would take the total over it is not added

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.10
    • changedInput schema / properties / max_index_size_mb / description
      Previous value: -"Size budget for all recommended indexes together, in MB (default 10000)"New value: +"Size budget for all recommended indexes together, in MB (default 10000); a candidate that would take the total over it is not added"
  2. First observedv0.1.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations cover the safety profile (readOnly, idempotent, non-destructive), and the description goes well beyond them: hypothetical indexes via hypopg, greedy addition under a 10% cost-improvement threshold, size budgeting, and a hard 30-second cutoff with partial results. It does not detail failure modes when hypopg is absent, which keeps it short of 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.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and scope, then mechanism, then output, then the sibling hand-off — a logical order with no filler sentences. It is dense as a single paragraph and the mid-sentence algorithm details (threshold, timeout) could be scannable, but nothing is redundant.

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?

There is no output schema, but the description enumerates what comes back: CREATE INDEX statements with sizes and costs, skipped queries with reasons, and before/after query costs. Combined with the algorithm constraints and prerequisites, an agent has everything needed to call it and interpret results.

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 coverage is 100% and the parameter is a simple size budget, so the baseline would be 3; the description adds real semantics by explaining that a candidate exceeding max_index_size_mb is simply not added, tying the parameter to search behavior rather than just restating it.

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?

Names a specific verb and resource ('Recommend indexes for this database's workload') and immediately defines the candidate scope (pg_stat_statements queries with ≥50 calls and ≥5 ms mean, top 100 by total time). It is plainly distinguishable from analyze_query_indexes, which it names for the per-query case.

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?

Explicitly routes the agent: this tool is workload-wide, and 'For queries you choose, use analyze_query_indexes' names the alternative and the condition selecting it. Prerequisites (pg_stat_statements, hypopg) are also stated so the agent can judge applicability up front.

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