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)
 

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  * coll OID of relevant collation, or 0 if none
78  * numbers float4 array (for statistical values)
79  * values anyarray (for representations of data values)
80  * The ID, operator, and collation fields are never NULL; they are zeroes
81  * in an unused slot. The numbers and values fields are NULL in an
82  * unused slot, and might also be NULL in a used slot if the slot kind
83  * has no need for one or the other.
84  * ----------------
85  */
86 
87  int16 stakind1;
88  int16 stakind2;
89  int16 stakind3;
90  int16 stakind4;
91  int16 stakind5;
92 
93  Oid staop1;
94  Oid staop2;
95  Oid staop3;
96  Oid staop4;
97  Oid staop5;
98 
99  Oid stacoll1;
100  Oid stacoll2;
101  Oid stacoll3;
102  Oid stacoll4;
103  Oid stacoll5;
104 
105 #ifdef CATALOG_VARLEN /* variable-length fields start here */
106  float4 stanumbers1[1];
107  float4 stanumbers2[1];
108  float4 stanumbers3[1];
109  float4 stanumbers4[1];
110  float4 stanumbers5[1];
111 
112  /*
113  * Values in these arrays are values of the column's data type, or of some
114  * related type such as an array element type. We presently have to cheat
115  * quite a bit to allow polymorphic arrays of this kind, but perhaps
116  * someday it'll be a less bogus facility.
117  */
118  anyarray stavalues1;
119  anyarray stavalues2;
120  anyarray stavalues3;
121  anyarray stavalues4;
122  anyarray stavalues5;
123 #endif
signed short int16
Definition: c.h:345
unsigned int Oid
Definition: postgres_ext.h:31
signed int int32
Definition: c.h:346
FormData_pg_statistic
Definition: pg_statistic.h:124
float float4
Definition: c.h:490

Variable Documentation

◆ FormData_pg_statistic

FormData_pg_statistic

Definition at line 124 of file pg_statistic.h.