Skip to main content
Glama

analyze_query_indexes

Read-onlyIdempotent

Recommends indexes for up to 10 SELECT queries using hypothetical-index search, returning CREATE INDEX statements, estimated sizes and costs, and before/after query costs without creating anything.

Instructions

Recommend indexes for up to 10 SELECT queries you give, each with weight 1, by the same hypothetical-index search as analyze_workload_indexes, with its 10% rule, max_index_size_mb and 30 second limit. Returns the same parts: CREATE INDEX statements with estimated sizes and costs, skipped queries with reasons, and each query's cost before and after. A query may hold values or $1-style placeholders; one with placeholders is costed with a generic plan. Statements that are not a SELECT are skipped with the reason. Nothing is created. Needs hypopg.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "queries": "<queries>"
    },
    "name": "analyze_query_indexes"
  }
}

Input Schema

NameRequiredDescriptionDefault
queriesYesUp to 10 SELECT queries, with values or with $1-style placeholders
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
Behavior5/5

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

Annotations already declare readOnlyHint/idempotent/non-destructive, but the description adds substantial context beyond them: the 10% rule, the 30-second limit, max_index_size_mb budgeting, generic-plan costing for $1 placeholders, and that non-SELECT statements are skipped with a reason. It also explicitly reassures 'Nothing is created' and flags the hypopg dependency, which is exactly the pre-call context an agent needs.

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 the core action and scope, then layers on return shape and constraints with no filler sentences. The second and third sentences are dense and slightly run-on (multiple clauses chained by commas), which keeps it just below top marks for structure.

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?

For a read-only, two-parameter analysis tool with no output schema, the description covers return contents (CREATE INDEX statements with sizes/costs, skipped queries with reasons, before/after costs), input nuances, limits, and the hypopg requirement. Nothing material an agent needs to invoke it correctly is missing.

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%, so the baseline is 3, but the description adds meaning beyond the schema: queries may contain literal values or $1-style placeholders, with placeholder queries costed via a generic plan. It also reinforces the size budget behavior for max_index_size_mb (a candidate exceeding the total is not added), adding nuance to the schema's wording.

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?

States a specific verb and resource ('Recommend indexes') plus the exact scope ('up to 10 SELECT queries you give, each with weight 1'), and positions itself against the sibling analyze_workload_indexes by noting it uses the same hypothetical-index search. An agent can distinguish this per-query recommender from the workload-level sibling without opening either schema.

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 'up to 10 SELECT queries' bound and the reference to analyze_workload_indexes give clear context for when this tool fits (small, explicit query sets) versus the workload variant. It stops short of explicit when-not-to-use guidance such as routing single-query explanation to explain_query, so it lands at 4 rather than 5.

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