1278 PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0);
1280 List *
args = (List *) PG_GETARG_POINTER(2);
1281 JoinType jointype = (JoinType) PG_GETARG_INT16(3);
1282 int mode = PG_GETARG_INT32(4);
1292 if (jointype != JOIN_INNER)
1294 elog(DEBUG1,
"%s: jointype %d not supported", __func__, jointype);
1299 arg1 = (Node*) linitial(
args);
1300 arg2 = (Node*) lsecond(
args);
1306 if (!IsA(arg1, Var) || !IsA(arg2, Var))
1308 elog(DEBUG1,
"%s called with arguments that are not column references", __func__);
1313 relid1 = rt_fetch(var1->varno, root->parse->rtable)->relid;
1314 relid2 = rt_fetch(var2->varno, root->parse->rtable)->relid;
1316 POSTGIS_DEBUGF(3,
"using relations \"%s\" Oid(%d), \"%s\" Oid(%d)",
1317 get_rel_name(relid1) ? get_rel_name(relid1) :
"NULL", relid1, get_rel_name(relid2) ? get_rel_name(relid2) :
"NULL", relid2);
1326 POSTGIS_DEBUGF(3,
"unable to retrieve stats for \"%s\" Oid(%d)", get_rel_name(relid1) ? get_rel_name(relid1) :
"NULL" , relid1);
1329 else if ( ! stats2 )
1331 POSTGIS_DEBUGF(3,
"unable to retrieve stats for \"%s\" Oid(%d)", get_rel_name(relid2) ? get_rel_name(relid2) :
"NULL", relid2);
1336 POSTGIS_DEBUGF(2,
"got selectivity %g", selectivity);
1340 PG_RETURN_FLOAT8(selectivity);
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?
N-dimensional statistics structure.