listExtendedStatistics

Return extended statistics objects (CREATE STATISTICS) for a schema with target table, columns, the statistics kinds declared (ndistinct, dependencies, mcv, expressions), and description -- plus whether they have actually been BUILT.

read-onlyany connectionsweeps instancesweeps group

Synopsis

listExtendedStatistics(schema)

Description

Return extended statistics objects (CREATE STATISTICS) for a schema with target table, columns, the statistics kinds declared (ndistinct, dependencies, mcv, expressions), and description -- plus whether they have actually been BUILT. pg_statistic_ext holds the definition and pg_statistic_ext_data holds the data, and an object that has never been ANALYZEd has the first and not the second: a catalog row, no statistics, and no effect on any plan.

'built' is false there and 'built_kinds' is empty, which is the difference between a fix that is in place and one that was declared and never finished -- the answer to the second is ANALYZE, not another CREATE STATISTICS. built_for_inherited says whether the data covers the parent alone, the whole inheritance tree, or both (PostgreSQL 15+, where stxdinherit became part of the key; null on 14, where the question cannot arise).

Parameters

schema requiredstring

Also accepts connection, instance, group, described once under arguments every tool takes.

Output

Keyed by statistics object name; each value is its target table, columns and kinds. An absent extension or a missing grant is reported as {error, hint} in place of the map.

Scope

A physical replica is byte-identical here, so asking each member of a replication group adds nothing.

Example mocked data

Request

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

Result

{
  "orders_city_postcode": {
    "table": "shop.customers",
    "columns": [
      "city",
      "postcode"
    ],
    "kinds": [
      "ndistinct",
      "dependencies"
    ],
    "built": true,
    "built_kinds": [
      "ndistinct",
      "dependencies"
    ],
    "built_for_inherited": false,
    "description": null
  }
}

Invented values on a fictional shop database, shaped by and checked against this tool's output schema. Real output is returned as structuredContent to clients that negotiate MCP 2025-06-18 or later.

See also

listSchemas, listTables, tableDetails, tableStats, largeObjects, listPartitions, partitionDetails, listTableStats, tableSize, listTableSizes, listFunctions, functionDetails, listEnums, enumDetails, listTypes, typeDetails, columnHistogram, listSequences