4 The view pg_stats provides access to the information stored in the
5 pg_statistic catalog. This view allows access only to rows of
6 pg_statistic that correspond to tables the user has permission to read,
7 and therefore it is safe to allow public read access to this view.
9 pg_stats is also designed to present the information in a more readable
10 format than the underlying catalog — at the cost that its schema must
11 be extended whenever new slot types are defined for pg_statistic.
13 Table 53.29. pg_stats Columns
19 schemaname name (references pg_namespace.nspname)
21 Name of schema containing table
23 tablename name (references pg_class.relname)
27 attname name (references pg_attribute.attname)
29 Name of column described by this row
33 If true, this row includes values from child tables, not just the
34 values in the specified table
38 Fraction of column entries that are null
42 Average width in bytes of column's entries
46 If greater than zero, the estimated number of distinct values in the
47 column. If less than zero, the negative of the number of distinct
48 values divided by the number of rows. (The negated form is used when
49 ANALYZE believes that the number of distinct values is likely to
50 increase as the table grows; the positive form is used when the column
51 seems to have a fixed number of possible values.) For example, -1
52 indicates a unique column in which the number of distinct values is the
53 same as the number of rows.
55 most_common_vals anyarray
57 A list of the most common values in the column. (Null if no values seem
58 to be more common than any others.)
60 most_common_freqs float4[]
62 A list of the frequencies of the most common values, i.e., number of
63 occurrences of each divided by total number of rows. (Null when
66 histogram_bounds anyarray
68 A list of values that divide the column's values into groups of
69 approximately equal population. The values in most_common_vals, if
70 present, are omitted from this histogram calculation. (This column is
71 null if the column data type does not have a < operator or if the
72 most_common_vals list accounts for the entire population.)
76 Statistical correlation between physical row ordering and logical
77 ordering of the column values. This ranges from -1 to +1. When the
78 value is near -1 or +1, an index scan on the column will be estimated
79 to be cheaper than when it is near zero, due to reduction of random
80 access to the disk. (This column is null if the column data type does
81 not have a < operator.)
83 most_common_elems anyarray
85 A list of non-null element values most often appearing within values of
86 the column. (Null for scalar types.)
88 most_common_elem_freqs float4[]
90 A list of the frequencies of the most common element values, i.e., the
91 fraction of rows containing at least one instance of the given value.
92 Two or three additional values follow the per-element frequencies;
93 these are the minimum and maximum of the preceding per-element
94 frequencies, and optionally the frequency of null elements. (Null when
95 most_common_elems is.)
97 elem_count_histogram float4[]
99 A histogram of the counts of distinct non-null element values within
100 the values of the column, followed by the average number of distinct
101 non-null elements. (Null for scalar types.)
103 range_length_histogram anyarray
105 A histogram of the lengths of non-empty and non-null range values of a
106 range type column. (Null for non-range types.)
108 This histogram is calculated using the subtype_diff range function
109 regardless of whether range bounds are inclusive.
111 range_empty_frac float4
113 Fraction of column entries whose values are empty ranges. (Null for
116 range_bounds_histogram anyarray
118 A histogram of lower and upper bounds of non-empty and non-null range
119 values. (Null for non-range types.)
121 These two histograms are represented as a single array of ranges, whose
122 lower bounds represent the histogram of lower bounds, and upper bounds
123 represent the histogram of upper bounds.
125 The maximum number of entries in the array fields can be controlled on
126 a column-by-column basis using the ALTER TABLE SET STATISTICS command,
127 or globally by setting the default_statistics_target run-time