| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * pg_statistic_d.h |
| 4 | * Macro definitions for pg_statistic |
| 5 | * |
| 6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| 7 | * Portions Copyright (c) 1994, Regents of the University of California |
| 8 | * |
| 9 | * NOTES |
| 10 | * ****************************** |
| 11 | * *** DO NOT EDIT THIS FILE! *** |
| 12 | * ****************************** |
| 13 | * |
| 14 | * It has been GENERATED by src/backend/catalog/genbki.pl |
| 15 | * |
| 16 | *------------------------------------------------------------------------- |
| 17 | */ |
| 18 | #ifndef PG_STATISTIC_D_H |
| 19 | #define PG_STATISTIC_D_H |
| 20 | |
| 21 | #define StatisticRelationId 2619 |
| 22 | |
| 23 | #define Anum_pg_statistic_starelid 1 |
| 24 | #define Anum_pg_statistic_staattnum 2 |
| 25 | #define Anum_pg_statistic_stainherit 3 |
| 26 | #define Anum_pg_statistic_stanullfrac 4 |
| 27 | #define Anum_pg_statistic_stawidth 5 |
| 28 | #define Anum_pg_statistic_stadistinct 6 |
| 29 | #define Anum_pg_statistic_stakind1 7 |
| 30 | #define Anum_pg_statistic_stakind2 8 |
| 31 | #define Anum_pg_statistic_stakind3 9 |
| 32 | #define Anum_pg_statistic_stakind4 10 |
| 33 | #define Anum_pg_statistic_stakind5 11 |
| 34 | #define Anum_pg_statistic_staop1 12 |
| 35 | #define Anum_pg_statistic_staop2 13 |
| 36 | #define Anum_pg_statistic_staop3 14 |
| 37 | #define Anum_pg_statistic_staop4 15 |
| 38 | #define Anum_pg_statistic_staop5 16 |
| 39 | #define Anum_pg_statistic_stacoll1 17 |
| 40 | #define Anum_pg_statistic_stacoll2 18 |
| 41 | #define Anum_pg_statistic_stacoll3 19 |
| 42 | #define Anum_pg_statistic_stacoll4 20 |
| 43 | #define Anum_pg_statistic_stacoll5 21 |
| 44 | #define Anum_pg_statistic_stanumbers1 22 |
| 45 | #define Anum_pg_statistic_stanumbers2 23 |
| 46 | #define Anum_pg_statistic_stanumbers3 24 |
| 47 | #define Anum_pg_statistic_stanumbers4 25 |
| 48 | #define Anum_pg_statistic_stanumbers5 26 |
| 49 | #define Anum_pg_statistic_stavalues1 27 |
| 50 | #define Anum_pg_statistic_stavalues2 28 |
| 51 | #define Anum_pg_statistic_stavalues3 29 |
| 52 | #define Anum_pg_statistic_stavalues4 30 |
| 53 | #define Anum_pg_statistic_stavalues5 31 |
| 54 | |
| 55 | #define Natts_pg_statistic 31 |
| 56 | |
| 57 | |
| 58 | /* |
| 59 | * Several statistical slot "kinds" are defined by core PostgreSQL, as |
| 60 | * documented below. Also, custom data types can define their own "kind" |
| 61 | * codes by mutual agreement between a custom typanalyze routine and the |
| 62 | * selectivity estimation functions of the type's operators. |
| 63 | * |
| 64 | * Code reading the pg_statistic relation should not assume that a particular |
| 65 | * data "kind" will appear in any particular slot. Instead, search the |
| 66 | * stakind fields to see if the desired data is available. (The standard |
| 67 | * function get_attstatsslot() may be used for this.) |
| 68 | */ |
| 69 | |
| 70 | /* |
| 71 | * The present allocation of "kind" codes is: |
| 72 | * |
| 73 | * 1-99: reserved for assignment by the core PostgreSQL project |
| 74 | * (values in this range will be documented in this file) |
| 75 | * 100-199: reserved for assignment by the PostGIS project |
| 76 | * (values to be documented in PostGIS documentation) |
| 77 | * 200-299: reserved for assignment by the ESRI ST_Geometry project |
| 78 | * (values to be documented in ESRI ST_Geometry documentation) |
| 79 | * 300-9999: reserved for future public assignments |
| 80 | * |
| 81 | * For private use you may choose a "kind" code at random in the range |
| 82 | * 10000-30000. However, for code that is to be widely disseminated it is |
| 83 | * better to obtain a publicly defined "kind" code by request from the |
| 84 | * PostgreSQL Global Development Group. |
| 85 | */ |
| 86 | |
| 87 | /* |
| 88 | * In a "most common values" slot, staop is the OID of the "=" operator |
| 89 | * used to decide whether values are the same or not, and stacoll is the |
| 90 | * collation used (same as column's collation). stavalues contains |
| 91 | * the K most common non-null values appearing in the column, and stanumbers |
| 92 | * contains their frequencies (fractions of total row count). The values |
| 93 | * shall be ordered in decreasing frequency. Note that since the arrays are |
| 94 | * variable-size, K may be chosen by the statistics collector. Values should |
| 95 | * not appear in MCV unless they have been observed to occur more than once; |
| 96 | * a unique column will have no MCV slot. |
| 97 | */ |
| 98 | #define STATISTIC_KIND_MCV 1 |
| 99 | |
| 100 | /* |
| 101 | * A "histogram" slot describes the distribution of scalar data. staop is |
| 102 | * the OID of the "<" operator that describes the sort ordering, and stacoll |
| 103 | * is the relevant collation. (In theory more than one histogram could appear, |
| 104 | * if a datatype has more than one useful sort operator or we care about more |
| 105 | * than one collation. Currently the collation will always be that of the |
| 106 | * underlying column.) stavalues contains M (>=2) non-null values that |
| 107 | * divide the non-null column data values into M-1 bins of approximately equal |
| 108 | * population. The first stavalues item is the MIN and the last is the MAX. |
| 109 | * stanumbers is not used and should be NULL. IMPORTANT POINT: if an MCV |
| 110 | * slot is also provided, then the histogram describes the data distribution |
| 111 | * *after removing the values listed in MCV* (thus, it's a "compressed |
| 112 | * histogram" in the technical parlance). This allows a more accurate |
| 113 | * representation of the distribution of a column with some very-common |
| 114 | * values. In a column with only a few distinct values, it's possible that |
| 115 | * the MCV list describes the entire data population; in this case the |
| 116 | * histogram reduces to empty and should be omitted. |
| 117 | */ |
| 118 | #define STATISTIC_KIND_HISTOGRAM 2 |
| 119 | |
| 120 | /* |
| 121 | * A "correlation" slot describes the correlation between the physical order |
| 122 | * of table tuples and the ordering of data values of this column, as seen |
| 123 | * by the "<" operator identified by staop with the collation identified by |
| 124 | * stacoll. (As with the histogram, more than one entry could theoretically |
| 125 | * appear.) stavalues is not used and should be NULL. stanumbers contains |
| 126 | * a single entry, the correlation coefficient between the sequence of data |
| 127 | * values and the sequence of their actual tuple positions. The coefficient |
| 128 | * ranges from +1 to -1. |
| 129 | */ |
| 130 | #define STATISTIC_KIND_CORRELATION 3 |
| 131 | |
| 132 | /* |
| 133 | * A "most common elements" slot is similar to a "most common values" slot, |
| 134 | * except that it stores the most common non-null *elements* of the column |
| 135 | * values. This is useful when the column datatype is an array or some other |
| 136 | * type with identifiable elements (for instance, tsvector). staop contains |
| 137 | * the equality operator appropriate to the element type, and stacoll |
| 138 | * contains the collation to use with it. stavalues contains |
| 139 | * the most common element values, and stanumbers their frequencies. Unlike |
| 140 | * MCV slots, frequencies are measured as the fraction of non-null rows the |
| 141 | * element value appears in, not the frequency of all rows. Also unlike |
| 142 | * MCV slots, the values are sorted into the element type's default order |
| 143 | * (to support binary search for a particular value). Since this puts the |
| 144 | * minimum and maximum frequencies at unpredictable spots in stanumbers, |
| 145 | * there are two extra members of stanumbers, holding copies of the minimum |
| 146 | * and maximum frequencies. Optionally, there can be a third extra member, |
| 147 | * which holds the frequency of null elements (expressed in the same terms: |
| 148 | * the fraction of non-null rows that contain at least one null element). If |
| 149 | * this member is omitted, the column is presumed to contain no null elements. |
| 150 | * |
| 151 | * Note: in current usage for tsvector columns, the stavalues elements are of |
| 152 | * type text, even though their representation within tsvector is not |
| 153 | * exactly text. |
| 154 | */ |
| 155 | #define STATISTIC_KIND_MCELEM 4 |
| 156 | |
| 157 | /* |
| 158 | * A "distinct elements count histogram" slot describes the distribution of |
| 159 | * the number of distinct element values present in each row of an array-type |
| 160 | * column. Only non-null rows are considered, and only non-null elements. |
| 161 | * staop contains the equality operator appropriate to the element type, |
| 162 | * and stacoll contains the collation to use with it. |
| 163 | * stavalues is not used and should be NULL. The last member of stanumbers is |
| 164 | * the average count of distinct element values over all non-null rows. The |
| 165 | * preceding M (>=2) members form a histogram that divides the population of |
| 166 | * distinct-elements counts into M-1 bins of approximately equal population. |
| 167 | * The first of these is the minimum observed count, and the last the maximum. |
| 168 | */ |
| 169 | #define STATISTIC_KIND_DECHIST 5 |
| 170 | |
| 171 | /* |
| 172 | * A "length histogram" slot describes the distribution of range lengths in |
| 173 | * rows of a range-type column. stanumbers contains a single entry, the |
| 174 | * fraction of empty ranges. stavalues is a histogram of non-empty lengths, in |
| 175 | * a format similar to STATISTIC_KIND_HISTOGRAM: it contains M (>=2) range |
| 176 | * values that divide the column data values into M-1 bins of approximately |
| 177 | * equal population. The lengths are stored as float8s, as measured by the |
| 178 | * range type's subdiff function. Only non-null rows are considered. |
| 179 | */ |
| 180 | #define STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM 6 |
| 181 | |
| 182 | /* |
| 183 | * A "bounds histogram" slot is similar to STATISTIC_KIND_HISTOGRAM, but for |
| 184 | * a range-type column. stavalues contains M (>=2) range values that divide |
| 185 | * the column data values into M-1 bins of approximately equal population. |
| 186 | * Unlike a regular scalar histogram, this is actually two histograms combined |
| 187 | * into a single array, with the lower bounds of each value forming a |
| 188 | * histogram of lower bounds, and the upper bounds a histogram of upper |
| 189 | * bounds. Only non-NULL, non-empty ranges are included. |
| 190 | */ |
| 191 | #define STATISTIC_KIND_BOUNDS_HISTOGRAM 7 |
| 192 | |
| 193 | |
| 194 | #endif /* PG_STATISTIC_D_H */ |
| 195 | |