Skip to main content
Glama

PostgreSQL-Performance-Tuner-Mcp

analyze_index_bloat

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

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)

Input Schema (JSON Schema)

{ "properties": { "index_name": { "description": "Name of a specific index to analyze", "type": "string" }, "min_bloat_percent": { "default": 20, "description": "Only show indexes with bloat above this percentage (default: 20)", "type": "number" }, "min_index_size_gb": { "default": 5, "description": "Minimum index size in GB to include (default: 5)", "type": "number" }, "schema_name": { "default": "public", "description": "Schema name (default: public)", "type": "string" }, "table_name": { "description": "Analyze all indexes on this table", "type": "string" } }, "required": [], "type": "object" }

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