PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
geo_selfuncs.c
Go to the documentation of this file.
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-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 *
11 * IDENTIFICATION
12 * src/backend/utils/adt/geo_selfuncs.c
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/fmgrprotos.h"
22
23
24/*
25 * Selectivity functions for geometric operators. These are bogus -- unless
26 * we know the actual key distribution in the index, we can't make a good
27 * prediction 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 a geometric index if one is available, so the selectivity had better
32 * be fairly small.
33 *
34 * In general, GiST needs 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. gistcostestimate(), 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
49{
50 PG_RETURN_FLOAT8(0.005);
51}
52
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
68{
70}
71
74{
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
87{
88 PG_RETURN_FLOAT8(0.001);
89}
90
93{
94 PG_RETURN_FLOAT8(0.001);
95}
#define PG_RETURN_FLOAT8(x)
Definition: fmgr.h:367
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
Datum areasel(PG_FUNCTION_ARGS)
Definition: geo_selfuncs.c:48
Datum positionsel(PG_FUNCTION_ARGS)
Definition: geo_selfuncs.c:67
Datum positionjoinsel(PG_FUNCTION_ARGS)
Definition: geo_selfuncs.c:73
Datum contsel(PG_FUNCTION_ARGS)
Definition: geo_selfuncs.c:86
Datum contjoinsel(PG_FUNCTION_ARGS)
Definition: geo_selfuncs.c:92
Datum areajoinsel(PG_FUNCTION_ARGS)
Definition: geo_selfuncs.c:54
uintptr_t Datum
Definition: postgres.h:69