1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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 ...
This commit is contained in:
Tom Lane
2000-02-17 03:40:02 +00:00
parent cf880a6160
commit 598ea2c359
12 changed files with 249 additions and 181 deletions

View File

@ -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.
* How likely is a box to be strictly left of (right of, above, below)
* a given box?
*/
/*
* left_sel -- 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