@@ -407,7 +407,8 @@ pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
407
407
/*
408
408
* get_cheapest_path_for_pathkeys
409
409
* Find the cheapest path (according to the specified criterion) that
410
- * satisfies the given pathkeys and parameterization.
410
+ * satisfies the given pathkeys and parameterization, and is parallel-safe
411
+ * if required.
411
412
* Return NULL if no such path.
412
413
*
413
414
* 'paths' is a list of possible paths that all generate the same relation
@@ -429,6 +430,10 @@ get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
429
430
{
430
431
Path * path = (Path * ) lfirst (l );
431
432
433
+ /* If required, reject paths that are not parallel-safe */
434
+ if (require_parallel_safe && !path -> parallel_safe )
435
+ continue ;
436
+
432
437
/*
433
438
* Since cost comparison is a lot cheaper than pathkey comparison, do
434
439
* that first. (XXX is that still true?)
@@ -437,9 +442,6 @@ get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
437
442
compare_path_costs (matched_path , path , cost_criterion ) <= 0 )
438
443
continue ;
439
444
440
- if (require_parallel_safe && !path -> parallel_safe )
441
- continue ;
442
-
443
445
if (pathkeys_contained_in (pathkeys , path -> pathkeys ) &&
444
446
bms_is_subset (PATH_REQ_OUTER (path ), required_outer ))
445
447
matched_path = path ;
0 commit comments