LCOV - code coverage report
Current view: top level - src/backend/utils/adt - geo_selfuncs.c (source / functions) Hit Total Coverage
Test: PostgreSQL 17devel Lines: 12 12 100.0 %
Date: 2024-04-16 23:11:07 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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-2024, 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             : 
      47             : Datum
      48         208 : areasel(PG_FUNCTION_ARGS)
      49             : {
      50         208 :     PG_RETURN_FLOAT8(0.005);
      51             : }
      52             : 
      53             : Datum
      54          66 : areajoinsel(PG_FUNCTION_ARGS)
      55             : {
      56          66 :     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         934 : positionsel(PG_FUNCTION_ARGS)
      68             : {
      69         934 :     PG_RETURN_FLOAT8(0.1);
      70             : }
      71             : 
      72             : Datum
      73         114 : positionjoinsel(PG_FUNCTION_ARGS)
      74             : {
      75         114 :     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         676 : contsel(PG_FUNCTION_ARGS)
      87             : {
      88         676 :     PG_RETURN_FLOAT8(0.001);
      89             : }
      90             : 
      91             : Datum
      92          30 : contjoinsel(PG_FUNCTION_ARGS)
      93             : {
      94          30 :     PG_RETURN_FLOAT8(0.001);
      95             : }

Generated by: LCOV version 1.14