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)
 
 DECLARE_TOAST (pg_statistic, 2840, 2841)
 
 DECLARE_UNIQUE_INDEX_PKEY (pg_statistic_relid_att_inh_index, 2696, StatisticRelidAttnumInhIndexId, pg_statistic, btree(starelid oid_ops, staattnum int2_ops, stainherit bool_ops))
 
 MAKE_SYSCACHE (STATRELATTINH, pg_statistic_relid_att_inh_index, 128)
 
 DECLARE_FOREIGN_KEY ((starelid, staattnum), pg_attribute,(attrelid, attnum))
 

Variables

 FormData_pg_statistic
 

Macro Definition Documentation

◆ STATISTIC_NUM_SLOTS

#define STATISTIC_NUM_SLOTS   5

Definition at line 127 of file pg_statistic.h.

Typedef Documentation

◆ Form_pg_statistic

Definition at line 135 of file pg_statistic.h.

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

References BKI_LOOKUP, and BKI_LOOKUP_OPT.

◆ DECLARE_FOREIGN_KEY()

DECLARE_FOREIGN_KEY ( (starelid, staattnum)  ,
pg_attribute  ,
(attrelid, attnum  
)

◆ DECLARE_TOAST()

DECLARE_TOAST ( pg_statistic  ,
2840  ,
2841   
)

◆ DECLARE_UNIQUE_INDEX_PKEY()

DECLARE_UNIQUE_INDEX_PKEY ( pg_statistic_relid_att_inh_index  ,
2696  ,
StatisticRelidAttnumInhIndexId  ,
pg_statistic  ,
btree(starelid oid_ops, staattnum int2_ops, stainherit bool_ops)   
)

◆ MAKE_SYSCACHE()

MAKE_SYSCACHE ( STATRELATTINH  ,
pg_statistic_relid_att_inh_index  ,
128   
)

Variable Documentation

◆ FormData_pg_statistic

FormData_pg_statistic

Definition at line 125 of file pg_statistic.h.