OSDN Git Service

Update copyright to 2004.
[pg-rex/syncrep.git] / src / backend / utils / adt / geo_selfuncs.c
1 /*-------------------------------------------------------------------------
2  *
3  * geo_selfuncs.c
4  *        Selectivity routines registered in the operator catalog in the
5  *        "oprrest" and "oprjoin" attributes.
6  *
7  * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  *
11  * IDENTIFICATION
12  *        $PostgreSQL: pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.23 2004/08/29 04:12:51 momjian Exp $
13  *
14  *      XXX These are totally bogus.  Perhaps someone will make them do
15  *      something reasonable, someday.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #include "postgres.h"
20
21 #include "utils/geo_decls.h"
22
23
24 /*
25  *      Selectivity functions for rtrees.  These are bogus -- unless we know
26  *      the actual key distribution in the index, we can't make a good prediction
27  *      of the selectivity of these operators.
28  *
29  *      Note: the values used here may look unreasonably small.  Perhaps they
30  *      are.  For now, we want to make sure that the optimizer will make use
31  *      of an r-tree index if one is available, so the selectivity had better
32  *      be fairly small.
33  *
34  *      In general, rtrees need to search multiple subtrees in order to guarantee
35  *      that all occurrences of the same key have been found.  Because of this,
36  *      the estimated cost for scanning the index ought to be higher than the
37  *      output selectivity would indicate.      rtcostestimate(), over in selfuncs.c,
38  *      ought to be adjusted accordingly --- but until we can generate somewhat
39  *      realistic numbers here, it hardly matters...
40  */
41
42
43 /*
44  * Selectivity for operators that depend on area, such as "overlap".
45  */
46
47 Datum
48 areasel(PG_FUNCTION_ARGS)
49 {
50         PG_RETURN_FLOAT8(0.005);
51 }
52
53 Datum
54 areajoinsel(PG_FUNCTION_ARGS)
55 {
56         PG_RETURN_FLOAT8(0.005);
57 }
58
59 /*
60  *      positionsel
61  *
62  * How likely is a box to be strictly left of (right of, above, below)
63  * a given box?
64  */
65
66 Datum
67 positionsel(PG_FUNCTION_ARGS)
68 {
69         PG_RETURN_FLOAT8(0.1);
70 }
71
72 Datum
73 positionjoinsel(PG_FUNCTION_ARGS)
74 {
75         PG_RETURN_FLOAT8(0.1);
76 }
77
78 /*
79  *      contsel -- How likely is a box to contain (be contained by) a given box?
80  *
81  * This is a tighter constraint than "overlap", so produce a smaller
82  * estimate than areasel does.
83  */
84
85 Datum
86 contsel(PG_FUNCTION_ARGS)
87 {
88         PG_RETURN_FLOAT8(0.001);
89 }
90
91 Datum
92 contjoinsel(PG_FUNCTION_ARGS)
93 {
94         PG_RETURN_FLOAT8(0.001);
95 }