PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ _postgis_gserialized_joinsel()

Datum _postgis_gserialized_joinsel ( PG_FUNCTION_ARGS  )

Definition at line 1982 of file gserialized_estimate.c.

1983{
1984 Oid table_oid1 = PG_GETARG_OID(0);
1985 text *att_text1 = PG_GETARG_TEXT_P(1);
1986 Oid table_oid2 = PG_GETARG_OID(2);
1987 text *att_text2 = PG_GETARG_TEXT_P(3);
1988 ND_STATS *nd_stats1, *nd_stats2;
1989 float8 selectivity = 0;
1990 int mode = 2; /* 2D mode by default */
1991
1992
1993 /* Retrieve the stats object */
1994 nd_stats1 = pg_get_nd_stats_by_name(table_oid1, att_text1, mode, false);
1995 nd_stats2 = pg_get_nd_stats_by_name(table_oid2, att_text2, mode, false);
1996
1997 if ( ! nd_stats1 )
1998 elog(ERROR, "stats for \"%s.%s\" do not exist", get_rel_name(table_oid1), text_to_cstring(att_text1));
1999
2000 if ( ! nd_stats2 )
2001 elog(ERROR, "stats for \"%s.%s\" do not exist", get_rel_name(table_oid2), text_to_cstring(att_text2));
2002
2003 /* Check if we've been asked to not use 2d mode */
2004 if ( ! PG_ARGISNULL(4) )
2005 {
2006 text *modetxt = PG_GETARG_TEXT_P(4);
2007 char *modestr = text_to_cstring(modetxt);
2008 if ( modestr[0] == 'N' )
2009 mode = 0;
2010 }
2011
2012 /* Do the estimation */
2013 selectivity = estimate_join_selectivity(nd_stats1, nd_stats2);
2014
2015 pfree(nd_stats1);
2016 pfree(nd_stats2);
2017 PG_RETURN_FLOAT8(selectivity);
2018}
static ND_STATS * pg_get_nd_stats_by_name(const Oid table_oid, const text *att_text, int mode, bool only_parent)
Pull the stats object from the PgSQL system catalogs.
static float8 estimate_join_selectivity(const ND_STATS *s1, const ND_STATS *s2)
Given two statistics histograms, what is the selectivity of a join driven by the && or &&& operator?

References estimate_join_selectivity(), and pg_get_nd_stats_by_name().

Here is the call graph for this function: