mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Postpone generate_gather_paths for topmost scan/join rel.
Don't call generate_gather_paths for the topmost scan/join relation when it is initially populated with paths. Instead, do the work in grouping_planner. By itself, this gains nothing; in fact it loses slightly because we end up calling set_cheapest() for the topmost scan/join rel twice rather than once. However, it paves the way for a future commit which will postpone generate_gather_paths for the topmost scan/join relation even further, allowing more accurate costing of parallel paths. Amit Kapila and Robert Haas. Earlier versions of this patch (which different substantially) were reviewed by Dilip Kumar, Amit Khandekar, Marina Polyakova, and Ashutosh Bapat.
This commit is contained in:
@@ -40,7 +40,7 @@ typedef struct
|
||||
} Clump;
|
||||
|
||||
static List *merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump,
|
||||
bool force);
|
||||
int num_gene, bool force);
|
||||
static bool desirable_join(PlannerInfo *root,
|
||||
RelOptInfo *outer_rel, RelOptInfo *inner_rel);
|
||||
|
||||
@@ -196,7 +196,7 @@ gimme_tree(PlannerInfo *root, Gene *tour, int num_gene)
|
||||
cur_clump->size = 1;
|
||||
|
||||
/* Merge it into the clumps list, using only desirable joins */
|
||||
clumps = merge_clump(root, clumps, cur_clump, false);
|
||||
clumps = merge_clump(root, clumps, cur_clump, num_gene, false);
|
||||
}
|
||||
|
||||
if (list_length(clumps) > 1)
|
||||
@@ -210,7 +210,7 @@ gimme_tree(PlannerInfo *root, Gene *tour, int num_gene)
|
||||
{
|
||||
Clump *clump = (Clump *) lfirst(lc);
|
||||
|
||||
fclumps = merge_clump(root, fclumps, clump, true);
|
||||
fclumps = merge_clump(root, fclumps, clump, num_gene, true);
|
||||
}
|
||||
clumps = fclumps;
|
||||
}
|
||||
@@ -235,7 +235,8 @@ gimme_tree(PlannerInfo *root, Gene *tour, int num_gene)
|
||||
* "desirable" joins.
|
||||
*/
|
||||
static List *
|
||||
merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, bool force)
|
||||
merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, int num_gene,
|
||||
bool force)
|
||||
{
|
||||
ListCell *prev;
|
||||
ListCell *lc;
|
||||
@@ -267,8 +268,14 @@ merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, bool force)
|
||||
/* Create paths for partitionwise joins. */
|
||||
generate_partitionwise_join_paths(root, joinrel);
|
||||
|
||||
/* Create GatherPaths for any useful partial paths for rel */
|
||||
generate_gather_paths(root, joinrel, false);
|
||||
/*
|
||||
* Except for the topmost scan/join rel, consider gathering
|
||||
* partial paths. We'll do the same for the topmost scan/join
|
||||
* rel once we know the final targetlist (see
|
||||
* grouping_planner).
|
||||
*/
|
||||
if (old_clump->size + new_clump->size < num_gene)
|
||||
generate_gather_paths(root, joinrel, false);
|
||||
|
||||
/* Find and save the cheapest paths for this joinrel */
|
||||
set_cheapest(joinrel);
|
||||
@@ -286,7 +293,7 @@ merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, bool force)
|
||||
* others. When no further merge is possible, we'll reinsert
|
||||
* it into the list.
|
||||
*/
|
||||
return merge_clump(root, clumps, old_clump, force);
|
||||
return merge_clump(root, clumps, old_clump, num_gene, force);
|
||||
}
|
||||
}
|
||||
prev = lc;
|
||||
|
Reference in New Issue
Block a user