Skip to main content
Glama

PostgreSQL-Performance-Tuner-Mcp

analyze_table_bloat

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

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

Input Schema (JSON Schema)

{ "properties": { "include_toast": { "default": false, "description": "Include TOAST table analysis if applicable", "type": "boolean" }, "min_table_size_gb": { "default": 5, "description": "Minimum table size in GB to include in schema-wide scan (default: 5)", "type": "number" }, "schema_name": { "default": "public", "description": "Schema name (default: public)", "type": "string" }, "table_name": { "description": "Name of the table to analyze (required if not using schema-wide scan)", "type": "string" }, "use_approx": { "default": false, "description": "Use pgstattuple_approx for faster but approximate results (recommended for large tables)", "type": "boolean" } }, "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