*** a/contrib/postgres_fdw/postgres_fdw.c
--- b/contrib/postgres_fdw/postgres_fdw.c
***************
*** 2937,2943 **** estimate_path_cost_size(PlannerInfo *root,
  			run_cost = ofpinfo->rel_total_cost - ofpinfo->rel_startup_cost;
  			run_cost += aggcosts.finalCost * numGroups;
  			run_cost += cpu_tuple_cost * numGroups;
! 			run_cost += ptarget->cost.per_tuple * numGroups;
  
  			/* Accout for the eval cost of HAVING quals, if any */
  			if (root->parse->havingQual)
--- 2937,2943 ----
  			run_cost = ofpinfo->rel_total_cost - ofpinfo->rel_startup_cost;
  			run_cost += aggcosts.finalCost * numGroups;
  			run_cost += cpu_tuple_cost * numGroups;
! 			run_cost += ptarget->cost.per_tuple * rows;
  
  			/* Accout for the eval cost of HAVING quals, if any */
  			if (root->parse->havingQual)
