PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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

BEGIN_CATALOG_STRUCT 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 131 of file pg_statistic.h.

Typedef Documentation

◆ Form_pg_statistic

Function Documentation

◆ CATALOG()

BEGIN_CATALOG_STRUCT CATALOG ( pg_statistic  ,
2619  ,
StatisticRelationId   
)

Definition at line 31 of file pg_statistic.h.

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

References BKI_LOOKUP, BKI_LOOKUP_OPT, and fb().

◆ DECLARE_FOREIGN_KEY()

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

◆ DECLARE_TOAST()

DECLARE_TOAST ( pg_statistic  ,
2840  ,
2841   
)

◆ DECLARE_UNIQUE_INDEX_PKEY()

◆ MAKE_SYSCACHE()

MAKE_SYSCACHE ( STATRELATTINH  ,
pg_statistic_relid_att_inh_index  ,
128   
)

Variable Documentation

◆ FormData_pg_statistic

FormData_pg_statistic

Definition at line 127 of file pg_statistic.h.