PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ gserialized_joinsel_internal()

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

Definition at line 1280 of file gserialized_estimate.c.

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

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