1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
2000-02-17 04:40:02 +01:00
|
|
|
* geo_selfuncs.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* Selectivity routines registered in the operator catalog in the
|
|
|
|
* "oprrest" and "oprjoin" attributes.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2010-01-02 17:58:17 +01:00
|
|
|
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2010-01-02 17:58:17 +01:00
|
|
|
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.33 2010/01/02 16:57:54 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-02-17 04:40:02 +01:00
|
|
|
* XXX These are totally bogus. Perhaps someone will make them do
|
|
|
|
* something reasonable, someday.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
2000-07-29 20:46:12 +02:00
|
|
|
#include "utils/geo_decls.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2006-04-27 00:33:36 +02:00
|
|
|
|
2000-02-17 04:40:02 +01:00
|
|
|
/*
|
2005-11-22 19:17:34 +01:00
|
|
|
* Selectivity functions for geometric operators. These are bogus -- unless
|
2005-11-07 18:36:47 +01:00
|
|
|
* we know the actual key distribution in the index, we can't make a good
|
|
|
|
* prediction of the selectivity of these operators.
|
2000-02-17 04:40:02 +01:00
|
|
|
*
|
|
|
|
* 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
|
2005-11-07 18:36:47 +01:00
|
|
|
* of a geometric index if one is available, so the selectivity had better
|
2000-02-17 04:40:02 +01:00
|
|
|
* be fairly small.
|
|
|
|
*
|
2005-11-07 18:36:47 +01:00
|
|
|
* In general, GiST needs to search multiple subtrees in order to guarantee
|
2000-02-17 04:40:02 +01:00
|
|
|
* 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
|
2005-11-07 18:36:47 +01:00
|
|
|
* output selectivity would indicate. gistcostestimate(), over in selfuncs.c,
|
2000-02-17 04:40:02 +01:00
|
|
|
* 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".
|
|
|
|
*/
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
areasel(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-02-15 18:55:17 +01:00
|
|
|
PG_RETURN_FLOAT8(0.005);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
areajoinsel(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-02-15 18:55:17 +01:00
|
|
|
PG_RETURN_FLOAT8(0.005);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-02-17 04:40:02 +01:00
|
|
|
* positionsel
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-02-17 04:40:02 +01:00
|
|
|
* How likely is a box to be strictly left of (right of, above, below)
|
|
|
|
* a given box?
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
positionsel(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
PG_RETURN_FLOAT8(0.1);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
positionjoinsel(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-06-05 09:29:25 +02:00
|
|
|
PG_RETURN_FLOAT8(0.1);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* contsel -- How likely is a box to contain (be contained by) a given box?
|
2000-02-17 04:40:02 +01:00
|
|
|
*
|
|
|
|
* This is a tighter constraint than "overlap", so produce a smaller
|
|
|
|
* estimate than areasel does.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2000-02-17 04:40:02 +01:00
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
contsel(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-02-15 18:55:17 +01:00
|
|
|
PG_RETURN_FLOAT8(0.001);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-06-05 09:29:25 +02:00
|
|
|
Datum
|
|
|
|
contjoinsel(PG_FUNCTION_ARGS)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-02-15 18:55:17 +01:00
|
|
|
PG_RETURN_FLOAT8(0.001);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|