mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Preparatory refactoring for parallel merge join support.
Extract the logic used by hash_inner_and_outer into a separate function, get_cheapest_parallel_safe_total_inner, so that it can also be used to plan parallel merge joins. Also, add a require_parallel_safe argument to the existing function get_cheapest_path_for_pathkeys, because parallel merge join needs to find the cheapest path for a given set of pathkeys that is parallel-safe, not just the cheapest one overall. Patch by me, reviewed by Dilip Kumar. Discussion: http://postgr.es/m/CA+TgmoYOv+dFK0MWW6366dFj_xTnohQfoBDrHyB7d1oZhrgPjA@mail.gmail.com
This commit is contained in:
@@ -337,11 +337,13 @@ pathkeys_contained_in(List *keys1, List *keys2)
|
||||
* 'pathkeys' represents a required ordering (in canonical form!)
|
||||
* 'required_outer' denotes allowable outer relations for parameterized paths
|
||||
* 'cost_criterion' is STARTUP_COST or TOTAL_COST
|
||||
* 'require_parallel_safe' causes us to consider only parallel-safe paths
|
||||
*/
|
||||
Path *
|
||||
get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
|
||||
Relids required_outer,
|
||||
CostSelector cost_criterion)
|
||||
CostSelector cost_criterion,
|
||||
bool require_parallel_safe)
|
||||
{
|
||||
Path *matched_path = NULL;
|
||||
ListCell *l;
|
||||
@@ -358,6 +360,9 @@ get_cheapest_path_for_pathkeys(List *paths, List *pathkeys,
|
||||
compare_path_costs(matched_path, path, cost_criterion) <= 0)
|
||||
continue;
|
||||
|
||||
if (require_parallel_safe && !path->parallel_safe)
|
||||
continue;
|
||||
|
||||
if (pathkeys_contained_in(pathkeys, path->pathkeys) &&
|
||||
bms_is_subset(PATH_REQ_OUTER(path), required_outer))
|
||||
matched_path = path;
|
||||
@@ -407,6 +412,28 @@ get_cheapest_fractional_path_for_pathkeys(List *paths,
|
||||
return matched_path;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_cheapest_parallel_safe_total_inner
|
||||
* Find the unparameterized parallel-safe path with the least total cost.
|
||||
*/
|
||||
Path *
|
||||
get_cheapest_parallel_safe_total_inner(List *paths)
|
||||
{
|
||||
ListCell *l;
|
||||
|
||||
foreach(l, paths)
|
||||
{
|
||||
Path *innerpath = (Path *) lfirst(l);
|
||||
|
||||
if (innerpath->parallel_safe &&
|
||||
bms_is_empty(PATH_REQ_OUTER(innerpath)))
|
||||
return innerpath;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* NEW PATHKEY FORMATION
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user