Skip to main content
Glama
foxter-io

PostgreSQL MCP Server

by foxter-io

Analyze Index Usage Statistics

pg_index_usage
Read-only

Identify unused or underused PostgreSQL indexes by analyzing scan counts and tuple statistics to remove storage waste and improve write performance.

Instructions

Show index scan counts and tuple statistics to identify unused or underused indexes.

Indexes with 0 scans that are not primary keys waste storage and slow writes — candidates for removal.

Args:

  • schema: Filter to a specific schema (optional)

  • min_table_size_mb: Only show indexes on tables larger than N MB (default: 0)

  • show_unused_only: Only show indexes with 0 scans (default: false)

  • response_format: Output format

Returns: JSON: { indexes: IndexUsage[], count: number } Markdown: table sorted by scan count ascending (least used first)

Note: Statistics reset on pg_stat_reset() or server restart. Low scans on a new server may not mean unused.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaNoFilter to schema (optional)
min_table_size_mbNoMinimum table size in MB to include
show_unused_onlyNoOnly show indexes with 0 scans
response_formatNoOutput format: 'markdown' for human-readable, 'json' for machine-readablemarkdown
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. Description adds valuable behavioral context: statistics reset on pg_stat_reset() or server restart, and low scans on new server may not indicate unused. This goes beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

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

Well-structured: one-line summary, motivational sentence, Args list, Returns section, behavioral note. Every sentence adds value. Front-loaded with key purpose. No fluff or repetition.

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?

Completeness given complexity: no output schema but description specifies return formats (JSON and Markdown) with sorting details for Markdown. Covers behavioral notes and all parameters. Standalone sufficient for agent to understand and invoke tool correctly.

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?

Input schema covers all 4 parameters with descriptions (100% coverage). Description repeats parameters in Args block with slight additional context (e.g., emphasis on filtering for unused indexes). Does not significantly add meaning beyond schema, but integrates parameters into the overall purpose. Baseline 3 is appropriate.

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?

Description clearly states 'Show index scan counts and tuple statistics to identify unused or underused indexes.' It uses a specific verb and resource, and distinguishes from sibling tools like pg_list_indexes (listing) and pg_bloat_report (bloat).

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?

Provides clear context for usage: identifying unused/underused indexes, mentions that indexes with 0 scans and not primary keys waste storage. Notes limitations about statistics reset and new server interpretation. Lacks explicit comparison to alternatives but sufficiently guides appropriate usage.

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/foxter-io/mcp-postgresql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server