Header And Logo

PostgreSQL
| The world's most advanced open source database.

geo_selfuncs.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * geo_selfuncs.c
00004  *    Selectivity routines registered in the operator catalog in the
00005  *    "oprrest" and "oprjoin" attributes.
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  *
00011  * IDENTIFICATION
00012  *    src/backend/utils/adt/geo_selfuncs.c
00013  *
00014  *  XXX These are totally bogus.  Perhaps someone will make them do
00015  *  something reasonable, someday.
00016  *
00017  *-------------------------------------------------------------------------
00018  */
00019 #include "postgres.h"
00020 
00021 #include "utils/geo_decls.h"
00022 
00023 
00024 /*
00025  *  Selectivity functions for geometric operators.  These are bogus -- unless
00026  *  we know the actual key distribution in the index, we can't make a good
00027  *  prediction of the selectivity of these operators.
00028  *
00029  *  Note: the values used here may look unreasonably small.  Perhaps they
00030  *  are.  For now, we want to make sure that the optimizer will make use
00031  *  of a geometric index if one is available, so the selectivity had better
00032  *  be fairly small.
00033  *
00034  *  In general, GiST needs to search multiple subtrees in order to guarantee
00035  *  that all occurrences of the same key have been found.  Because of this,
00036  *  the estimated cost for scanning the index ought to be higher than the
00037  *  output selectivity would indicate.  gistcostestimate(), over in selfuncs.c,
00038  *  ought to be adjusted accordingly --- but until we can generate somewhat
00039  *  realistic numbers here, it hardly matters...
00040  */
00041 
00042 
00043 /*
00044  * Selectivity for operators that depend on area, such as "overlap".
00045  */
00046 
00047 Datum
00048 areasel(PG_FUNCTION_ARGS)
00049 {
00050     PG_RETURN_FLOAT8(0.005);
00051 }
00052 
00053 Datum
00054 areajoinsel(PG_FUNCTION_ARGS)
00055 {
00056     PG_RETURN_FLOAT8(0.005);
00057 }
00058 
00059 /*
00060  *  positionsel
00061  *
00062  * How likely is a box to be strictly left of (right of, above, below)
00063  * a given box?
00064  */
00065 
00066 Datum
00067 positionsel(PG_FUNCTION_ARGS)
00068 {
00069     PG_RETURN_FLOAT8(0.1);
00070 }
00071 
00072 Datum
00073 positionjoinsel(PG_FUNCTION_ARGS)
00074 {
00075     PG_RETURN_FLOAT8(0.1);
00076 }
00077 
00078 /*
00079  *  contsel -- How likely is a box to contain (be contained by) a given box?
00080  *
00081  * This is a tighter constraint than "overlap", so produce a smaller
00082  * estimate than areasel does.
00083  */
00084 
00085 Datum
00086 contsel(PG_FUNCTION_ARGS)
00087 {
00088     PG_RETURN_FLOAT8(0.001);
00089 }
00090 
00091 Datum
00092 contjoinsel(PG_FUNCTION_ARGS)
00093 {
00094     PG_RETURN_FLOAT8(0.001);
00095 }