PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ gserialized_joinsel_internal()

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

Definition at line 1121 of file gserialized_estimate.c.

1122{
1123 float8 selectivity;
1124 Oid relid1, relid2;
1125 ND_STATS *stats1, *stats2;
1126 Node *arg1 = (Node*) linitial(args);
1127 Node *arg2 = (Node*) lsecond(args);
1128 Var *var1 = (Var*) arg1;
1129 Var *var2 = (Var*) arg2;
1130
1131 POSTGIS_DEBUGF(2, "%s: entered function", __func__);
1132
1133 /* We only do column joins right now, no functional joins */
1134 /* TODO: handle g1 && ST_Expand(g2) */
1135 if (!IsA(arg1, Var) || !IsA(arg2, Var))
1136 {
1137 POSTGIS_DEBUGF(1, "%s called with arguments that are not column references", __func__);
1138 return DEFAULT_ND_JOINSEL;
1139 }
1140
1141 /* What are the Oids of our tables/relations? */
1142 relid1 = rt_fetch(var1->varno, root->parse->rtable)->relid;
1143 relid2 = rt_fetch(var2->varno, root->parse->rtable)->relid;
1144
1145 /* Pull the stats from the stats system. */
1146 stats1 = pg_get_nd_stats(relid1, var1->varattno, mode, false);
1147 stats2 = pg_get_nd_stats(relid2, var2->varattno, mode, false);
1148
1149 /* If we can't get stats, we have to stop here! */
1150 if (!stats1)
1151 {
1152 POSTGIS_DEBUGF(2, "%s: cannot find stats for \"%s\"", __func__, get_rel_name(relid2) ? get_rel_name(relid2) : "NULL");
1153 return DEFAULT_ND_JOINSEL;
1154 }
1155 else if (!stats2)
1156 {
1157 POSTGIS_DEBUGF(2, "%s: cannot find stats for \"%s\"", __func__, get_rel_name(relid2) ? get_rel_name(relid2) : "NULL");
1158 return DEFAULT_ND_JOINSEL;
1159 }
1160
1161 selectivity = estimate_join_selectivity(stats1, stats2);
1162 POSTGIS_DEBUGF(2, "got selectivity %g", selectivity);
1163 pfree(stats1);
1164 pfree(stats2);
1165 return selectivity;
1166}
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?

References 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: