Help Center > > Developer Guide> System Catalogs and System Views> System Catalogs> PG_STATISTIC

PG_STATISTIC

Updated at: Jul 15, 2020 GMT+08:00

PG_STATISTIC records statistics about tables and index columns in a database. It is accessible only to users with system administrator rights.

Table 1 PG_STATISTIC columns

Name

Type

Description

starelid

oid

Table or index which the described column belongs to

starelkind

"char"

Type of an object

staattnum

smallint

Number of the described column in the table, starting from 1

stainherit

Boolean

Whether to collect statistics for objects that have inheritance relationship

stanullfrac

real

Percentage of column entries that are null

stawidth

integer

Average stored width, in bytes, of non-null entries

stadistinct

real

Number of distinct, not-null data values in the column for all DNs

  • 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 values appear about twice on the average can be represented by stadistinct = -0.5.)
  • A zero value means the number of distinct values is unknown.

stakindN

smallint

Code number stating that the type of statistics is stored in Slot N of the pg_statistic row.

Value range: 1 to 5

staopN

oid

Operator used to generate the statistics stored in Slot N. For example, a histogram slot shows the < operator that defines the sort order of the data.

Value range: 1 to 5

stanumbersN

real[]

Numerical statistics of the appropriate type for Slot N. The value is null if the slot kind does not involve numerical values.

Value range: 1 to 5

stavaluesN

anyarray

Column data values of the appropriate type for Slot N. The value is null if the slot type does not store any data values. Each array's element values are actually of the specific column's data type so there is no way to define these columns' type more specifically than anyarray.

Value range: 1 to 5

stadndistinct

real

Number of unique non-null data values in the dn1 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 values appear about twice on the average can be represented by stadistinct = -0.5.)
  • A zero value means the number of distinct values is unknown.

staextinfo

text

Information about extension statistics (reserved)

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel