diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
new file mode 100644
index f2d6385..e7cd6df
*** a/src/backend/optimizer/util/pathnode.c
--- b/src/backend/optimizer/util/pathnode.c
*************** apply_projection_to_path(PlannerInfo *ro
*** 2417,2422 ****
--- 2417,2424 ----
  								   gpath->subpath->parent,
  								   gpath->subpath,
  								   target);
+ 		path->total_cost -= (target->cost.per_tuple - oldcost.per_tuple) * path->rows;
+ 		path->total_cost += (target->cost.per_tuple - oldcost.per_tuple) * gpath->subpath->rows;
  	}
  	else if (path->parallel_safe &&
  			 !is_parallel_safe(root, (Node *) target->exprs))
