postgres_fdw: oddity in costing aggregate pushdown paths

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: postgres_fdw: oddity in costing aggregate pushdown paths
Date: 2018-11-27 12:55:09
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


While working on [1], I noticed that since we don't set the selectivity
and cost of the local_conds (i.e., fpinfo->local_conds_sel and
fpinfo->local_conds_cost) properly in add_foreign_grouping_paths and
foreign_grouping_ok, estimate_path_cost_size produces considerably
underestimated results when use_remote_estimate. I think this would
cause problems in later planning steps. So, why not add something like
this to add_foreign_grouping_paths, as done in other functions such as

--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -5496,6 +5496,19 @@ add_foreign_grouping_paths(PlannerInfo *root,
if (!foreign_grouping_ok(root, grouped_rel, extra->havingQual))

+ /*
+ * Compute the selectivity and cost of the local_conds, so we don't have
+ * to do it over again for each path. The best we can do for these
+ * conditions is to estimate selectivity on the basis of local
+ */
+ fpinfo->local_conds_sel = clauselist_selectivity(root,
+ fpinfo->local_conds,
+ 0,
+ NULL);
+ cost_qual_eval(&fpinfo->local_conds_cost, fpinfo->local_conds, root);
/* Estimate the cost of push down */
estimate_path_cost_size(root, grouped_rel, NIL, NIL, &rows,
&width, &startup_cost, &total_cost);

Best regards,
Etsuro Fujita



Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-11-27 12:55:13 Re: Inadequate executor locking of indexes
Previous Message Peter Eisentraut 2018-11-27 12:45:20 Re: pgsql: Integrate recovery.conf into postgresql.conf