PostgreSQL Source Code  git master
pg_statistic.h File Reference
#include "catalog/genbki.h"
#include "catalog/pg_statistic_d.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 STATISTIC_NUM_SLOTS   5
 

Typedefs

typedef FormData_pg_statisticForm_pg_statistic
 

Functions

 CATALOG (pg_statistic, 2619, StatisticRelationId) BKI_WITHOUT_OIDS
 

Variables

 FormData_pg_statistic
 

Macro Definition Documentation

◆ STATISTIC_NUM_SLOTS

#define STATISTIC_NUM_SLOTS   5

Typedef Documentation

◆ Form_pg_statistic

Function Documentation

◆ CATALOG()

CATALOG ( pg_statistic  ,
2619  ,
StatisticRelationId   
)

Definition at line 29 of file pg_statistic.h.

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

Variable Documentation

◆ FormData_pg_statistic

FormData_pg_statistic

Definition at line 117 of file pg_statistic.h.