1262{
1263 float8 selectivity;
1264 Oid relid1, relid2;
1266 Node *arg1 = (Node*) linitial(args);
1267 Node *arg2 = (Node*) lsecond(args);
1268 Var *var1 = (Var*) arg1;
1269 Var *var2 = (Var*) arg2;
1270
1271 POSTGIS_DEBUGF(2, "%s: entered function", __func__);
1272
1273
1274
1275 if (!IsA(arg1, Var) || !IsA(arg2, Var))
1276 {
1277 POSTGIS_DEBUGF(1, "%s called with arguments that are not column references", __func__);
1279 }
1280
1281
1282 relid1 = rt_fetch(var1->varno, root->parse->rtable)->relid;
1283 relid2 = rt_fetch(var2->varno, root->parse->rtable)->relid;
1284
1285
1288
1289
1290 if (!stats1)
1291 {
1292 POSTGIS_DEBUGF(2, "%s: cannot find stats for \"%s\"", __func__, get_rel_name(relid2) ? get_rel_name(relid2) : "NULL");
1294 }
1295 else if (!stats2)
1296 {
1297 POSTGIS_DEBUGF(2, "%s: cannot find stats for \"%s\"", __func__, get_rel_name(relid2) ? get_rel_name(relid2) : "NULL");
1299 }
1300
1302 POSTGIS_DEBUGF(2, "got selectivity %g", selectivity);
1303 pfree(stats1);
1304 pfree(stats2);
1305 return selectivity;
1306}
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.