diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-17 03:40:02 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-17 03:40:02 +0000 |
commit | 598ea2c359ef625f472a2a53b870a1baffa45251 (patch) | |
tree | 688b6309e4c9ae3a05e8cd53e0d034a64c2a0e2c /src/backend/utils/adt/geo_selfuncs.c | |
parent | cf880a616023c9b8c127660461dadc69d894ab50 (diff) | |
download | postgresql-598ea2c359ef625f472a2a53b870a1baffa45251.tar.gz postgresql-598ea2c359ef625f472a2a53b870a1baffa45251.zip |
Finish repairing 6.5's problems with r-tree indexes: create appropriate
selectivity functions and make the r-tree operators use them. The
estimation functions themselves are just stubs, unfortunately, but
perhaps someday someone will make them compute realistic estimates.
Change pg_am so that the optimizer can reliably tell the difference
between ordered and unordered indexes --- before it would think that
an r-tree index can be scanned in '<<' order, which is not right AFAIK.
Repair broken negator links for network_sup and related ops.
Initdb forced. This might be my last initdb force for 7.0 ... hope so
anyway ...
Diffstat (limited to 'src/backend/utils/adt/geo_selfuncs.c')
-rw-r--r-- | src/backend/utils/adt/geo_selfuncs.c | 98 |
1 files changed, 53 insertions, 45 deletions
diff --git a/src/backend/utils/adt/geo_selfuncs.c b/src/backend/utils/adt/geo_selfuncs.c index 9dd0de0e424..95e594ea0ef 100644 --- a/src/backend/utils/adt/geo_selfuncs.c +++ b/src/backend/utils/adt/geo_selfuncs.c @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- * - * geo-selfuncs.c + * geo_selfuncs.c * Selectivity routines registered in the operator catalog in the * "oprrest" and "oprjoin" attributes. * @@ -9,9 +9,10 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.12 2000/01/26 05:57:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.13 2000/02/17 03:39:42 tgl Exp $ * - * XXX These are totally bogus. + * XXX These are totally bogus. Perhaps someone will make them do + * something reasonable, someday. * *------------------------------------------------------------------------- */ @@ -19,17 +20,41 @@ #include "utils/builtins.h" + +/* + * Selectivity functions for rtrees. These are bogus -- unless we know + * the actual key distribution in the index, we can't make a good prediction + * of the selectivity of these operators. + * + * Note: the values used here may look unreasonably small. Perhaps they + * are. For now, we want to make sure that the optimizer will make use + * of an r-tree index if one is available, so the selectivity had better + * be fairly small. + * + * In general, rtrees need to search multiple subtrees in order to guarantee + * that all occurrences of the same key have been found. Because of this, + * the estimated cost for scanning the index ought to be higher than the + * output selectivity would indicate. rtcostestimate(), over in selfuncs.c, + * ought to be adjusted accordingly --- but until we can generate somewhat + * realistic numbers here, it hardly matters... + */ + + +/* + * Selectivity for operators that depend on area, such as "overlap". + */ + float64 areasel(Oid opid, Oid relid, AttrNumber attno, - char *value, + Datum value, int32 flag) { float64 result; result = (float64) palloc(sizeof(float64data)); - *result = 1.0 / 4.0; + *result = 0.05; return result; } @@ -43,81 +68,66 @@ areajoinsel(Oid opid, float64 result; result = (float64) palloc(sizeof(float64data)); - *result = 1.0 / 4.0; + *result = 0.05; return result; } /* - * Selectivity functions for rtrees. These are bogus -- unless we know - * the actual key distribution in the index, we can't make a good prediction - * of the selectivity of these operators. + * positionsel * - * In general, rtrees need to search multiple subtrees in order to guarantee - * that all occurrences of the same key have been found. Because of this, - * the heuristic selectivity functions we return are higher than they would - * otherwise be. - */ - -/* - * left_sel -- How likely is a box to be strictly left of (right of, above, - * below) a given box? + * How likely is a box to be strictly left of (right of, above, below) + * a given box? */ -#ifdef NOT_USED float64 -leftsel(Oid opid, - Oid relid, - AttrNumber attno, - char *value, - int32 flag) +positionsel(Oid opid, + Oid relid, + AttrNumber attno, + Datum value, + int32 flag) { float64 result; result = (float64) palloc(sizeof(float64data)); - *result = 1.0 / 6.0; + *result = 0.1; return result; } -#endif - -#ifdef NOT_USED float64 -leftjoinsel(Oid opid, - Oid relid1, - AttrNumber attno1, - Oid relid2, - AttrNumber attno2) +positionjoinsel(Oid opid, + Oid relid1, + AttrNumber attno1, + Oid relid2, + AttrNumber attno2) { float64 result; result = (float64) palloc(sizeof(float64data)); - *result = 1.0 / 6.0; + *result = 0.1; return result; } -#endif - /* * contsel -- How likely is a box to contain (be contained by) a given box? + * + * This is a tighter constraint than "overlap", so produce a smaller + * estimate than areasel does. */ -#ifdef NOT_USED + float64 contsel(Oid opid, Oid relid, AttrNumber attno, - char *value, + Datum value, int32 flag) { float64 result; result = (float64) palloc(sizeof(float64data)); - *result = 1.0 / 10.0; + *result = 0.01; return result; } -#endif - -#ifdef NOT_USED float64 contjoinsel(Oid opid, Oid relid1, @@ -128,8 +138,6 @@ contjoinsel(Oid opid, float64 result; result = (float64) palloc(sizeof(float64data)); - *result = 1.0 / 10.0; + *result = 0.01; return result; } - -#endif |