Skip to main content
Glama

Column statistics

pg_column_stats
Read-onlyIdempotent

Inspect planner statistics for table columns without reading data: NULL fractions, distinct values, widths, common values, histograms and correlation. Use it to spot selective, skewed or empty columns before writing queries or indexes.

Instructions

Describe the data of each column from the planner statistics, without reading the table: fraction of NULLs, estimated number of distinct values, average width in bytes, the most common values with their frequency (up to 10), the range of the histogram, and the correlation with the physical order (near 1 or -1 means sorted).

Use it to see which columns are selective, skewed or mostly empty before writing a query or an index. The numbers come from the last ANALYZE; a table never analyzed has none, and the answer says so. For protected columns and columns whose name looks like a credential only the statistics are given, never sample values.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "table": "<table>"
    },
    "name": "pg_column_stats"
  }
}

Input Schema

NameRequiredDescriptionDefault
tableYes
columnsNo
connectionNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/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, so the safety profile is covered. The description adds genuine behavioral context beyond that: numbers derive from the last ANALYZE, never-analyzed tables return an explanatory response, MCV lists cap at 10, and protected or credential-like columns suppress sample values. That last point is a real data-governance caveat an agent could not infer otherwise.

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?

Three sentences, front-loaded with the core action and scope, then the metric list, then usage and caveats. The long inline enumeration of metrics is dense but each item is informative. No filler sentences.

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?

There is no output schema, and the description effectively compensates by naming the per-column fields returned (NULL fraction, ndistinct estimate, average width, MCVs with frequencies, histogram range, correlation) plus the empty-stats and redaction cases. The only material gap is the undocumented 'columns' and 'connection' parameters.

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

Parameters2/5

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

Schema description coverage is 0% across three parameters, so the description carries the full burden — and it says nothing about any parameter. It never explains that 'columns' narrows the output to a subset or what 'connection' selects, leaving two of three parameters undocumented anywhere. Only 'table' is self-evident from its name.

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 opens with a specific verb and resource ('Describe the data of each column from the planner statistics') and immediately scopes it ('without reading the table'), which cleanly separates it from table-level or index-level siblings like pg_table_stats and pg_index_stats. It then enumerates the exact metrics returned, so an agent knows precisely what it gets.

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?

It gives a concrete use case ('see which columns are selective, skewed or mostly empty before writing a query or an index'), which is clear when-to-use guidance. It stops short of naming alternatives or stating when not to use it (e.g., preferring pg_describe_table for types/constraints), so it falls 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.