pg_statistic — PostgreSQL system catalog

The PostgreSQL pg_statistic system catalog: full column reference (names, types, descriptions), catalog relationships and version support.

Summary

The catalog pg_statistic stores statistical data about the contents of the database. Entries are created by ANALYZE and subsequently used by the query planner. Note that all the statistical data is inherently approximate, even assuming that it is up-to-date.

(Description quoted from the official PostgreSQL documentation.)

Columns

The pg_statistic system catalog exposes the following columns (names, types and descriptions are taken verbatim from the PostgreSQL documentation):

  • starelid oid references pg_class.oid
    The table or index that the described column belongs to
  • staattnum int2 references pg_attribute.attnum
    The number of the described column
  • stainherit bool
    If true, the stats include values from child tables, not just the values in the specified relation
  • stanullfrac float4
    The fraction of the column’s entries that are null
  • stawidth int4
    The average stored width, in bytes, of nonnull entries
  • stadistinct float4
    The number of distinct nonnull data values in the column. A value greater than zero is the actual number of distinct values. A value less than zero is the negative of a multiplier for the number of rows in the table; for example, a column in which about 80% of the values are nonnull and each nonnull value appears about twice on average could be represented by stadistinct = -0.4. A zero value means the number of distinct values is unknown.
  • stakindN int2
    A code number indicating the kind of statistics stored in the Nth “slot” of the pg_statistic row.
  • staopN oid references pg_operator.oid
    An operator used to derive the statistics stored in the Nth “slot”. For example, a histogram slot would show the < operator that defines the pathkeys/">sort order of the data. Zero if the statistics kind does not require an operator.
  • stacollN oid references pg_collation.oid
    The collation used to derive the statistics stored in the Nth “slot”. For example, a histogram slot for a collatable column would show the collation that defines the sort order of the data. Zero for noncollatable data.
  • stanumbersN float4[]
    Numerical statistics of the appropriate kind for the Nth “slot”, or null if the slot kind does not involve numerical values
  • stavaluesN anyarray
    Column data values of the appropriate kind for the Nth “slot”, or null if the slot kind does not store any data values. Each array’s element values are actually of the specific column’s data type, or a related type such as an array’s element type, so there is no way to define these columns’ type more specifically than anyarray.

Related catalogs

This object references the following other system catalogs:

Version applicability

Present in PostgreSQL 17, 18, 19 (verified against each release’s documentation). This is a long-standing system object that also exists in earlier PostgreSQL releases.

Related & references

Reference: PostgreSQL documentation — pg_statistic.