Hi,
While testing of Asynchronous Append feature with TPC-H queries, I found
that the push-down JOIN technique is rarely used.
For my servers fdw_tuple_cost = 0.2, fdw_startup_cost = 100.
Exploring the code, i found in postgres_fdw, estimate_path_cost_size(),
lines 2908,2909:
run_cost += nrows * join_cost.per_tuple;
nrows = clamp_row_est(nrows * fpinfo->joinclause_sel);
Above:
nrows = fpinfo_i->rows * fpinfo_o->rows;
Maybe it is needed to swap lines 2908 and 2909 (see attachment)?
In my case of two big partitioned tables and small join result it
strongly influenced on choice of the JOIN push-down strategy.
--
regards,
Andrey Lepikhov
Postgres Professional
diff --git a/contrib/postgres_fdw/postgres_fdw.c
b/contrib/postgres_fdw/postgres_fdw.c
index b6c72e1d1e..3047300c4b 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -2905,8 +2905,8 @@ estimate_path_cost_size(PlannerInfo *root,
*/
run_cost = fpinfo_i->rel_total_cost -
fpinfo_i->rel_startup_cost;
run_cost += fpinfo_o->rel_total_cost -
fpinfo_o->rel_startup_cost;
- run_cost += nrows * join_cost.per_tuple;
nrows = clamp_row_est(nrows * fpinfo->joinclause_sel);
+ run_cost += nrows * join_cost.per_tuple;
run_cost += nrows * remote_conds_cost.per_tuple;
run_cost += fpinfo->local_conds_cost.per_tuple *
retrieved_rows;