PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ gserialized_joinsel_internal()

double gserialized_joinsel_internal ( PlannerInfo *  root,
List *  args,
JoinType  jointype,
int  mode 
)

Definition at line 1275 of file gserialized_estimate.c.

1276 {
1277  float8 selectivity;
1278  Oid relid1, relid2;
1279  ND_STATS *stats1, *stats2;
1280  Node *arg1 = (Node*) linitial(args);
1281  Node *arg2 = (Node*) lsecond(args);
1282  Var *var1 = (Var*) arg1;
1283  Var *var2 = (Var*) arg2;
1284 
1285  POSTGIS_DEBUGF(2, "%s: entered function", __func__);
1286 
1287  /* We only do column joins right now, no functional joins */
1288  /* TODO: handle g1 && ST_Expand(g2) */
1289  if (!IsA(arg1, Var) || !IsA(arg2, Var))
1290  {
1291  POSTGIS_DEBUGF(1, "%s called with arguments that are not column references", __func__);
1292  return DEFAULT_ND_JOINSEL;
1293  }
1294 
1295  /* What are the Oids of our tables/relations? */
1296  relid1 = rt_fetch(var1->varno, root->parse->rtable)->relid;
1297  relid2 = rt_fetch(var2->varno, root->parse->rtable)->relid;
1298 
1299  /* Pull the stats from the stats system. */
1300  stats1 = pg_get_nd_stats(relid1, var1->varattno, mode, false);
1301  stats2 = pg_get_nd_stats(relid2, var2->varattno, mode, false);
1302 
1303  /* If we can't get stats, we have to stop here! */
1304  if (!stats1)
1305  {
1306  POSTGIS_DEBUGF(2, "%s: cannot find stats for \"%s\"", __func__, get_rel_name(relid2) ? get_rel_name(relid2) : "NULL");
1307  return DEFAULT_ND_JOINSEL;
1308  }
1309  else if (!stats2)
1310  {
1311  POSTGIS_DEBUGF(2, "%s: cannot find stats for \"%s\"", __func__, get_rel_name(relid2) ? get_rel_name(relid2) : "NULL");
1312  return DEFAULT_ND_JOINSEL;
1313  }
1314 
1315  selectivity = estimate_join_selectivity(stats1, stats2);
1316  POSTGIS_DEBUGF(2, "got selectivity %g", selectivity);
1317  pfree(stats1);
1318  pfree(stats2);
1319  return selectivity;
1320 }
static ND_STATS * pg_get_nd_stats(const Oid table_oid, AttrNumber att_num, int mode, bool only_parent)
Pull the stats object from the PgSQL system catalogs.
#define DEFAULT_ND_JOINSEL
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?
args
Definition: ovdump.py:45
N-dimensional statistics structure.

References ovdump::args, DEFAULT_ND_JOINSEL, estimate_join_selectivity(), and pg_get_nd_stats().

Referenced by gserialized_gist_joinsel(), and postgis_index_supportfn().

Here is the call graph for this function:
Here is the caller graph for this function: