diff options
| author | Tom Lane | 1999-08-01 04:54:25 +0000 |
|---|---|---|
| committer | Tom Lane | 1999-08-01 04:54:25 +0000 |
| commit | 44878506d811dcb5e7f4ea6450c9e6b8544f2651 (patch) | |
| tree | c4b6c4af148bab7667b2b93bdec2f060bf638d80 /src/include | |
| parent | f851c6b07deac83e03de3e77221ea595513e6f47 (diff) | |
First step in fixing selectivity-estimation code. eqsel and
neqsel now behave as per my suggestions in pghackers a few days ago.
selectivity for < > <= >= should work OK for integral types as well, but
still need work for nonintegral types. Since these routines have never
actually executed before :-(, this may result in some significant changes
in the optimizer's choices of execution plans. Let me know if you see
any serious misbehavior.
CAUTION: THESE CHANGES REQUIRE INITDB. pg_statistic table has changed.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/pg_statistic.h | 42 | ||||
| -rw-r--r-- | src/include/commands/vacuum.h | 11 | ||||
| -rw-r--r-- | src/include/utils/builtins.h | 10 |
3 files changed, 44 insertions, 19 deletions
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h index 19b87b68b1b..1c719443282 100644 --- a/src/include/catalog/pg_statistic.h +++ b/src/include/catalog/pg_statistic.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_statistic.h,v 1.6 1999/02/13 23:21:15 momjian Exp $ + * $Id: pg_statistic.h,v 1.7 1999/08/01 04:54:21 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,11 +32,32 @@ */ CATALOG(pg_statistic) { - Oid starelid; - int2 staattnum; - Oid staop; - text stalokey; /* VARIABLE LENGTH FIELD */ - text stahikey; /* VARIABLE LENGTH FIELD */ + /* These fields form the unique key for the entry: */ + Oid starelid; /* relation containing attribute */ + int2 staattnum; /* attribute (column) stats are for */ + Oid staop; /* '<' comparison op used for lo/hi vals */ + /* Note: the current VACUUM code will never produce more than one entry + * per column, but in theory there could be multiple entries if a datatype + * has more than one useful ordering operator. Also, the current code + * will not write an entry unless it found at least one non-NULL value + * in the column; so the remaining fields will never be NULL. + */ + + /* These fields contain the stats about the column indicated by the key */ + float4 stanullfrac; /* the fraction of the entries that are NULL */ + float4 stacommonfrac; /* the fraction that are the most common val */ + + /* THE REST OF THESE ARE VARIABLE LENGTH FIELDS. + * They cannot be accessed as C struct entries; you have to use the + * full field access machinery (heap_getattr) for them. + * + * All three of these are text representations of data values of the + * column's data type. To re-create the actual Datum, do + * datatypein(textout(givenvalue)). + */ + text stacommonval; /* most common non-null value in column */ + text staloval; /* smallest non-null value in column */ + text stahival; /* largest non-null value in column */ } FormData_pg_statistic; /* ---------------- @@ -50,11 +71,14 @@ typedef FormData_pg_statistic *Form_pg_statistic; * compiler constants for pg_statistic * ---------------- */ -#define Natts_pg_statistic 5 +#define Natts_pg_statistic 8 #define Anum_pg_statistic_starelid 1 #define Anum_pg_statistic_staattnum 2 #define Anum_pg_statistic_staop 3 -#define Anum_pg_statistic_stalokey 4 -#define Anum_pg_statistic_stahikey 5 +#define Anum_pg_statistic_stanullfrac 4 +#define Anum_pg_statistic_stacommonfrac 5 +#define Anum_pg_statistic_stacommonval 6 +#define Anum_pg_statistic_staloval 7 +#define Anum_pg_statistic_stahival 8 #endif /* PG_STATISTIC_H */ diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 59a72bbb15b..59a7fe4a506 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: vacuum.h,v 1.22 1999/07/15 15:21:03 momjian Exp $ + * $Id: vacuum.h,v 1.23 1999/08/01 04:54:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -67,22 +67,23 @@ typedef struct guess2, max, min; - int16 best_len, + int best_len, guess1_len, guess2_len, max_len, min_len; - int32 best_cnt, + long best_cnt, guess1_cnt, guess1_hits, guess2_hits, null_cnt, - nonnull_cnt; - int32 max_cnt, + nonnull_cnt, + max_cnt, min_cnt; FmgrInfo f_cmpeq, f_cmplt, f_cmpgt; + Oid op_cmplt; regproc outfunc; bool initialized; } VacAttrStats; diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index e6a0b4157d5..dfe1897cbe2 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.84 1999/07/16 17:07:39 momjian Exp $ + * $Id: builtins.h,v 1.85 1999/08/01 04:54:20 tgl Exp $ * * NOTES * This should normally only be included by fmgr.h. @@ -372,10 +372,10 @@ extern Oid regproctooid(RegProcedure rp); #define RegprocToOid(rp) regproctooid(rp) /* selfuncs.c */ -extern float64 eqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); -extern float64 neqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); -extern float64 intltsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag); -extern float64 intgtsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag); +extern float64 eqsel(Oid opid, Oid relid, AttrNumber attno, Datum value, int32 flag); +extern float64 neqsel(Oid opid, Oid relid, AttrNumber attno, Datum value, int32 flag); +extern float64 intltsel(Oid opid, Oid relid, AttrNumber attno, Datum value, int32 flag); +extern float64 intgtsel(Oid opid, Oid relid, AttrNumber attno, Datum value, int32 flag); extern float64 eqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); extern float64 neqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); extern float64 intltjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); |
