Skip to main content
Glama
isdaniel

PostgreSQL-Performance-Tuner-Mcp

analyze_index_bloat

Read-onlyIdempotent

Analyze PostgreSQL index bloat to identify fragmented indexes that need REINDEX operations, improve query performance, and reduce storage waste by examining leaf page density and fragmentation percentages.

Instructions

Analyze index bloat using pgstatindex from pgstattuple extension.

Note: This tool analyzes only user/client indexes and excludes PostgreSQL system indexes (pg_catalog, information_schema, pg_toast). This focuses the analysis on your application's custom indexes.

Uses pgstatindex to get B-tree index statistics including:

  • Leaf page density (avg_leaf_density) - lower values indicate more bloat

  • Fragmentation percentage

  • Empty and deleted pages

Helps identify indexes that:

  • Need REINDEX to improve performance

  • Have high fragmentation

  • Are wasting storage space

Requires the pgstattuple extension: CREATE EXTENSION IF NOT EXISTS pgstattuple;

Note: Also supports GIN indexes (pgstatginindex) and Hash indexes (pgstathashindex).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
index_nameNoName of a specific index to analyze
table_nameNoAnalyze all indexes on this table
schema_nameNoSchema name (default: public)public
min_index_size_gbNoMinimum index size in GB to include (default: 5)
min_bloat_percentNoOnly show indexes with bloat above this percentage (default: 20)
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false, covering safety and idempotency. The description adds valuable context beyond this: it specifies the tool analyzes only user indexes (excluding system ones), requires the pgstattuple extension, and lists the types of statistics returned (leaf page density, fragmentation percentage, empty/deleted pages), which helps the agent understand the tool's scope and prerequisites without contradicting annotations.

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, scope exclusion, statistics details, use cases, prerequisites, and additional support. It is appropriately sized and front-loaded with key information, though the note about GIN/Hash indexes at the end could be integrated more seamlessly, and some sentences are slightly verbose.

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 moderate complexity (5 parameters, no output schema), the description is mostly complete: it explains the tool's purpose, scope, statistics, use cases, and prerequisites. However, it lacks details on output format (e.g., what the return data looks like) and does not mention performance implications or limitations (e.g., impact on database during analysis), leaving minor gaps in contextual understanding.

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?

Schema description coverage is 100%, so the input schema fully documents all five parameters (index_name, table_name, schema_name, min_index_size_gb, min_bloat_percent). The description does not add any parameter-specific details beyond what the schema provides, such as explaining interactions between parameters or usage examples, so it meets the baseline of 3 without compensating for gaps.

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 analyzes index bloat using pgstatindex, specifies it focuses on user/client indexes while excluding system indexes, and distinguishes it from sibling tools like analyze_table_bloat and get_bloat_summary by its specific focus on index-level analysis rather than table-level or summary-level analysis.

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 (to identify indexes needing REINDEX, with high fragmentation, or wasting storage) and mentions it supports GIN and Hash indexes via other functions. However, it does not explicitly state when not to use it or directly compare it to alternatives like find_unused_indexes or get_index_recommendations among the siblings.

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