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