Simon Riggs <simon@2ndQuadrant.com> writes:
> + if (removable &&
> + joinrel->cheapest_total_path < keeprel->cheapest_total_path)
> + {
> + elog(LOG, "join removed");
> + joinrel->pathlist = keeprel->pathlist;
> + joinrel->joininfo = keeprel->baserestrictinfo;
> + }
> + }
On third thought: if you think that the join paths could possibly win,
then the correct coding here is something like
foreach(path, keeprel->pathlist)
add_path(joinrel, ...)
The reason is that it's not an all-or-nothing choice: some of the paths
might offer cheaper startup cost, or present a useful sort order.
So just present them as available alternatives and let add_path sort it
out.
regards, tom lane