Skip to main content
Glama

Table statistics

pg_table_stats
Read-onlyIdempotent

Inspect per-table PostgreSQL activity to identify sequential-scan-heavy tables, dead-row buildup, and tables missed by autovacuum; filter by schema/table and rank by scans, changes, size, or cache hit.

Instructions

Show per-table activity from pg_stat_user_tables: sequential and index scans, rows inserted, updated (and HOT updated) and deleted, live and dead rows, rows changed since the last analyze, last vacuum/autovacuum/analyze/autoanalyze and the cache hit ratio.

Use it to find tables read by sequential scans, tables full of dead rows and tables that autovacuum has not touched. Filter with schema and table (name, schema.name, or a pattern with *). order_by picks the ranking; cache_hit lists the worst first. Counters accumulate since the statistics were reset (shown as counters_since).

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "pg_table_stats"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
tableNo
schemaNo
order_byNoseq_scan
connectionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, non-destructive and closed-world. The description still adds real behavior: counters accumulate since the statistics reset and are surfaced as `counters_since`, and `cache_hit` ordering returns worst-first — neither is derivable from the 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?

Front-loaded with what is returned before how to filter, in three tight paragraphs with no filler. Slightly long, but nearly every clause names a distinct column or semantic.

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?

With no output schema, the description enumerates the returned columns and clarifies the two non-obvious ones (counters_since, cache_hit ordering). Only the undocumented `limit` and `connection` parameters leave a gap for an agent composing a call.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description carries the burden and does: `table`/`schema` accept a bare name, `schema.name`, or a `*` pattern, and `order_by` selects the ranking. `limit` and `connection` are left undocumented, which keeps it below a 5.

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?

States a specific verb ('show per-table activity') bound to a concrete source ('pg_stat_user_tables') and enumerates the returned metrics. The 'per-table' scope implicitly but clearly separates it from column- and index-level stats siblings.

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?

Gives three concrete diagnostic use cases: tables read by sequential scans, tables full of dead rows, and tables autovacuum has not touched. No explicit 'not for this' guidance or named alternatives, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.