PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pg_statistic.h File Reference
#include "catalog/genbki.h"
Include dependency graph for pg_statistic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define StatisticRelationId   2619
 
#define STATISTIC_NUM_SLOTS   5
 
#define Natts_pg_statistic   26
 
#define Anum_pg_statistic_starelid   1
 
#define Anum_pg_statistic_staattnum   2
 
#define Anum_pg_statistic_stainherit   3
 
#define Anum_pg_statistic_stanullfrac   4
 
#define Anum_pg_statistic_stawidth   5
 
#define Anum_pg_statistic_stadistinct   6
 
#define Anum_pg_statistic_stakind1   7
 
#define Anum_pg_statistic_stakind2   8
 
#define Anum_pg_statistic_stakind3   9
 
#define Anum_pg_statistic_stakind4   10
 
#define Anum_pg_statistic_stakind5   11
 
#define Anum_pg_statistic_staop1   12
 
#define Anum_pg_statistic_staop2   13
 
#define Anum_pg_statistic_staop3   14
 
#define Anum_pg_statistic_staop4   15
 
#define Anum_pg_statistic_staop5   16
 
#define Anum_pg_statistic_stanumbers1   17
 
#define Anum_pg_statistic_stanumbers2   18
 
#define Anum_pg_statistic_stanumbers3   19
 
#define Anum_pg_statistic_stanumbers4   20
 
#define Anum_pg_statistic_stanumbers5   21
 
#define Anum_pg_statistic_stavalues1   22
 
#define Anum_pg_statistic_stavalues2   23
 
#define Anum_pg_statistic_stavalues3   24
 
#define Anum_pg_statistic_stavalues4   25
 
#define Anum_pg_statistic_stavalues5   26
 
#define STATISTIC_KIND_MCV   1
 
#define STATISTIC_KIND_HISTOGRAM   2
 
#define STATISTIC_KIND_CORRELATION   3
 
#define STATISTIC_KIND_MCELEM   4
 
#define STATISTIC_KIND_DECHIST   5
 
#define STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM   6
 
#define STATISTIC_KIND_BOUNDS_HISTOGRAM   7
 

Typedefs

typedef FormData_pg_statisticForm_pg_statistic
 

Functions

 CATALOG (pg_statistic, 2619) BKI_WITHOUT_OIDS
 

Variables

 FormData_pg_statistic
 

Macro Definition Documentation

#define Anum_pg_statistic_staattnum   2

Definition at line 137 of file pg_statistic.h.

Referenced by RemoveStatistics(), and update_attstats().

#define Anum_pg_statistic_stadistinct   6

Definition at line 141 of file pg_statistic.h.

Referenced by update_attstats().

#define Anum_pg_statistic_stainherit   3

Definition at line 138 of file pg_statistic.h.

Referenced by update_attstats().

#define Anum_pg_statistic_stakind1   7

Definition at line 142 of file pg_statistic.h.

Referenced by update_attstats().

#define Anum_pg_statistic_stakind2   8

Definition at line 143 of file pg_statistic.h.

#define Anum_pg_statistic_stakind3   9

Definition at line 144 of file pg_statistic.h.

#define Anum_pg_statistic_stakind4   10

Definition at line 145 of file pg_statistic.h.

#define Anum_pg_statistic_stakind5   11

Definition at line 146 of file pg_statistic.h.

#define Anum_pg_statistic_stanullfrac   4

Definition at line 139 of file pg_statistic.h.

Referenced by update_attstats().

#define Anum_pg_statistic_stanumbers1   17

Definition at line 152 of file pg_statistic.h.

Referenced by get_attstatsslot(), and update_attstats().

#define Anum_pg_statistic_stanumbers2   18

Definition at line 153 of file pg_statistic.h.

#define Anum_pg_statistic_stanumbers3   19

Definition at line 154 of file pg_statistic.h.

#define Anum_pg_statistic_stanumbers4   20

Definition at line 155 of file pg_statistic.h.

#define Anum_pg_statistic_stanumbers5   21

Definition at line 156 of file pg_statistic.h.

#define Anum_pg_statistic_staop1   12

Definition at line 147 of file pg_statistic.h.

Referenced by update_attstats().

#define Anum_pg_statistic_staop2   13

Definition at line 148 of file pg_statistic.h.

#define Anum_pg_statistic_staop3   14

Definition at line 149 of file pg_statistic.h.

#define Anum_pg_statistic_staop4   15

Definition at line 150 of file pg_statistic.h.

#define Anum_pg_statistic_staop5   16

Definition at line 151 of file pg_statistic.h.

#define Anum_pg_statistic_starelid   1

Definition at line 136 of file pg_statistic.h.

Referenced by RemoveStatistics(), and update_attstats().

#define Anum_pg_statistic_stavalues1   22

Definition at line 157 of file pg_statistic.h.

Referenced by get_attstatsslot(), and update_attstats().

#define Anum_pg_statistic_stavalues2   23

Definition at line 158 of file pg_statistic.h.

#define Anum_pg_statistic_stavalues3   24

Definition at line 159 of file pg_statistic.h.

#define Anum_pg_statistic_stavalues4   25

Definition at line 160 of file pg_statistic.h.

#define Anum_pg_statistic_stavalues5   26

Definition at line 161 of file pg_statistic.h.

#define Anum_pg_statistic_stawidth   5

Definition at line 140 of file pg_statistic.h.

Referenced by update_attstats().

#define Natts_pg_statistic   26

Definition at line 135 of file pg_statistic.h.

Referenced by update_attstats().

#define STATISTIC_KIND_BOUNDS_HISTOGRAM   7

Definition at line 292 of file pg_statistic.h.

Referenced by calc_hist_selectivity(), and compute_range_stats().

#define STATISTIC_KIND_CORRELATION   3

Definition at line 233 of file pg_statistic.h.

Referenced by btcostestimate(), and compute_scalar_stats().

#define STATISTIC_KIND_DECHIST   5
#define STATISTIC_KIND_MCELEM   4
#define STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM   6

Definition at line 281 of file pg_statistic.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and compute_range_stats().

#define STATISTIC_NUM_SLOTS   5
#define StatisticRelationId   2619

Typedef Documentation

Function Documentation

CATALOG ( pg_statistic  ,
2619   
)

Definition at line 31 of file pg_statistic.h.

32 {
33  /* These fields form the unique key for the entry: */
34  Oid starelid; /* relation containing attribute */
35  int16 staattnum; /* attribute (column) stats are for */
36  bool stainherit; /* true if inheritance children are included */
37 
38  /* the fraction of the column's entries that are NULL: */
39  float4 stanullfrac;
40 
41  /*
42  * stawidth is the average width in bytes of non-null entries. For
43  * fixed-width datatypes this is of course the same as the typlen, but for
44  * var-width types it is more useful. Note that this is the average width
45  * of the data as actually stored, post-TOASTing (eg, for a
46  * moved-out-of-line value, only the size of the pointer object is
47  * counted). This is the appropriate definition for the primary use of
48  * the statistic, which is to estimate sizes of in-memory hash tables of
49  * tuples.
50  */
51  int32 stawidth;
52 
53  /* ----------------
54  * stadistinct indicates the (approximate) number of distinct non-null
55  * data values in the column. The interpretation is:
56  * 0 unknown or not computed
57  * > 0 actual number of distinct values
58  * < 0 negative of multiplier for number of rows
59  * The special negative case allows us to cope with columns that are
60  * unique (stadistinct = -1) or nearly so (for example, a column in which
61  * non-null values appear about twice on the average could be represented
62  * by stadistinct = -0.5 if there are no nulls, or -0.4 if 20% of the
63  * column is nulls). Because the number-of-rows statistic in pg_class may
64  * be updated more frequently than pg_statistic is, it's important to be
65  * able to describe such situations as a multiple of the number of rows,
66  * rather than a fixed number of distinct values. But in other cases a
67  * fixed number is correct (eg, a boolean column).
68  * ----------------
69  */
70  float4 stadistinct;
71 
72  /* ----------------
73  * To allow keeping statistics on different kinds of datatypes,
74  * we do not hard-wire any particular meaning for the remaining
75  * statistical fields. Instead, we provide several "slots" in which
76  * statistical data can be placed. Each slot includes:
77  * kind integer code identifying kind of data (see below)
78  * op OID of associated operator, if needed
79  * numbers float4 array (for statistical values)
80  * values anyarray (for representations of data values)
81  * The ID and operator fields are never NULL; they are zeroes in an
82  * unused slot. The numbers and values fields are NULL in an unused
83  * slot, and might also be NULL in a used slot if the slot kind has
84  * no need for one or the other.
85  * ----------------
86  */
87 
88  int16 stakind1;
89  int16 stakind2;
90  int16 stakind3;
91  int16 stakind4;
92  int16 stakind5;
93 
94  Oid staop1;
95  Oid staop2;
96  Oid staop3;
97  Oid staop4;
98  Oid staop5;
99 
100 #ifdef CATALOG_VARLEN /* variable-length fields start here */
101  float4 stanumbers1[1];
102  float4 stanumbers2[1];
103  float4 stanumbers3[1];
104  float4 stanumbers4[1];
105  float4 stanumbers5[1];
106 
107  /*
108  * Values in these arrays are values of the column's data type, or of some
109  * related type such as an array element type. We presently have to cheat
110  * quite a bit to allow polymorphic arrays of this kind, but perhaps
111  * someday it'll be a less bogus facility.
112  */
113  anyarray stavalues1;
114  anyarray stavalues2;
115  anyarray stavalues3;
116  anyarray stavalues4;
117  anyarray stavalues5;
118 #endif
signed short int16
Definition: c.h:252
unsigned int Oid
Definition: postgres_ext.h:31
signed int int32
Definition: c.h:253
FormData_pg_statistic
Definition: pg_statistic.h:119
float float4
Definition: c.h:377

Variable Documentation

FormData_pg_statistic

Definition at line 119 of file pg_statistic.h.