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):
starelidoidreferencespg_class.oid
The table or index that the described column belongs tostaattnumint2referencespg_attribute.attnum
The number of the described columnstainheritbool
If true, the stats include values from child tables, not just the values in the specified relationstanullfracfloat4
The fraction of the column’s entries that are nullstawidthint4
The average stored width, in bytes, of nonnull entriesstadistinctfloat4
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.stakindNint2
A code number indicating the kind of statistics stored in the Nth “slot” of the pg_statistic row.staopNoidreferencespg_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.stacollNoidreferencespg_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.stanumbersNfloat4[]
Numerical statistics of the appropriate kind for the Nth “slot”, or null if the slot kind does not involve numerical valuesstavaluesNanyarray
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:
starelid→pg_classstaattnum→pg_attributestaopN→pg_operatorstacollN→pg_collation
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.