Skip to main content
Glama
isdaniel

PostgreSQL-Performance-Tuner-Mcp

analyze_table_bloat

Read-onlyIdempotent

Identify PostgreSQL table bloat by analyzing dead tuples and free space to determine when VACUUM operations are needed for performance optimization and disk space reclamation.

Instructions

Analyze table bloat using the pgstattuple extension.

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

Uses pgstattuple to get accurate tuple-level statistics including:

  • Dead tuple count and percentage

  • Free space within the table

  • Physical vs logical table size

This helps identify tables that:

  • Need VACUUM to reclaim space

  • Need VACUUM FULL to reclaim disk space

  • Have high bloat affecting performance

Requires the pgstattuple extension to be installed: CREATE EXTENSION IF NOT EXISTS pgstattuple;

Note: pgstattuple performs a full table scan, so use with caution on large tables. For large tables, consider using pgstattuple_approx instead (use_approx=true).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameNoName of the table to analyze (required if not using schema-wide scan)
schema_nameNoSchema name (default: public)public
use_approxNoUse pgstattuple_approx for faster but approximate results (recommended for large tables)
min_table_size_gbNoMinimum table size in GB to include in schema-wide scan (default: 5)
include_toastNoInclude TOAST table analysis if applicable
Behavior4/5

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

Annotations already indicate readOnlyHint=true, destructiveHint=false, and idempotentHint=true, covering safety and idempotency. The description adds valuable context beyond this: it warns about performance impact (full table scan on large tables), mentions the need for extension installation, and clarifies scope (excludes system tables). No contradictions with annotations exist.

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, statistics, use cases, prerequisites, and cautions). It's appropriately detailed for a complex tool, though slightly verbose. Every sentence adds value, such as explaining exclusion of system tables and performance considerations.

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 complexity (5 parameters, no output schema) and rich annotations, the description is largely complete. It covers purpose, usage, behavioral traits, and context. However, it doesn't detail the output format or example results, which could be helpful since there's no output schema. This minor gap prevents a perfect score.

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 5 parameters. The description adds some semantic context by explaining the purpose of use_approx (for large tables) and the focus on user tables, but it doesn't provide additional parameter details beyond what's in the schema. This meets the baseline for high schema coverage.

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 table bloat using the pgstattuple extension, specifying it focuses on user/client tables while excluding system tables. It distinguishes itself from sibling tools like 'get_bloat_summary' or 'get_table_stats' by emphasizing tuple-level statistics and bloat analysis for maintenance decisions.

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?

The description provides explicit guidance on when to use this tool (for identifying tables needing VACUUM or VACUUM FULL due to bloat) and when to consider alternatives (using pgstattuple_approx for large tables via use_approx=true). It also mentions prerequisites (pgstattuple extension installation) and cautions about full table scans on large tables.

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