Skip to content

Commit fdfa562

Browse files
author
Commitfest Bot
committed
[CF 4285] v1 - Revise get_cheapest_parallel_safe_total_inner
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/4285 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAMbWs49xR_2T1BPDw+vO4Bs7pqYiQn4aNaWdmA9BdVEaHhtktg@mail.gmail.com Author(s): Richard Guo
2 parents 12efa48 + 7ae815d commit fdfa562

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/backend/optimizer/path/pathkeys.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,18 +698,25 @@ get_cheapest_fractional_path_for_pathkeys(List *paths,
698698
Path *
699699
get_cheapest_parallel_safe_total_inner(List *paths)
700700
{
701+
Path *matched_path = NULL;
701702
ListCell *l;
702703

703704
foreach(l, paths)
704705
{
705706
Path *innerpath = (Path *) lfirst(l);
706707

707-
if (innerpath->parallel_safe &&
708-
bms_is_empty(PATH_REQ_OUTER(innerpath)))
709-
return innerpath;
708+
if (!innerpath->parallel_safe ||
709+
!bms_is_empty(PATH_REQ_OUTER(innerpath)))
710+
continue;
711+
712+
if (matched_path != NULL &&
713+
compare_path_costs(matched_path, innerpath, TOTAL_COST) <= 0)
714+
continue;
715+
716+
matched_path = innerpath;
710717
}
711718

712-
return NULL;
719+
return matched_path;
713720
}
714721

715722
/****************************************************************************

0 commit comments

Comments
 (0)