1238 PlannerInfo *root = (PlannerInfo *) PG_GETARG_POINTER(0);
1240 List *
args = (List *) PG_GETARG_POINTER(2);
1241 JoinType jointype = (JoinType) PG_GETARG_INT16(3);
1242 int mode = PG_GETARG_INT32(4);
1252 if (jointype != JOIN_INNER)
1254 elog(DEBUG1,
"%s: jointype %d not supported", __func__, jointype);
1259 arg1 = (Node*) linitial(args);
1260 arg2 = (Node*) lsecond(args);
1266 if (!IsA(arg1, Var) || !IsA(arg2, Var))
1268 elog(DEBUG1,
"%s called with arguments that are not column references", __func__);
1273 relid1 = rt_fetch(var1->varno, root->parse->rtable)->relid;
1274 relid2 = rt_fetch(var2->varno, root->parse->rtable)->relid;
1276 POSTGIS_DEBUGF(3,
"using relations \"%s\" Oid(%d), \"%s\" Oid(%d)",
1277 get_rel_name(relid1) ? get_rel_name(relid1) :
"NULL", relid1, get_rel_name(relid2) ? get_rel_name(relid2) :
"NULL", relid2);
1286 POSTGIS_DEBUGF(3,
"unable to retrieve stats for \"%s\" Oid(%d)", get_rel_name(relid1) ? get_rel_name(relid1) :
"NULL" , relid1);
1289 else if ( ! stats2 )
1291 POSTGIS_DEBUGF(3,
"unable to retrieve stats for \"%s\" Oid(%d)", get_rel_name(relid2) ? get_rel_name(relid2) :
"NULL", relid2);
1296 POSTGIS_DEBUGF(2,
"got selectivity %g", selectivity);
1300 PG_RETURN_FLOAT8(selectivity);
#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.
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.