diff options
author | David Rowley <drowley@postgresql.org> | 2023-10-05 21:03:10 +1300 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2023-10-05 21:03:10 +1300 |
commit | a8a968a8212ee3ef7f22795c834b33d871fac262 (patch) | |
tree | f5e16eb7247a6472cb7e81a7ec9ff7507fc29e1f /src/backend/optimizer/path/allpaths.c | |
parent | 0b053e78b5990cd01e7169ee5bd2bb8e4045deea (diff) | |
download | postgresql-a8a968a8212ee3ef7f22795c834b33d871fac262.tar.gz postgresql-a8a968a8212ee3ef7f22795c834b33d871fac262.zip |
Consider cheap startup paths in add_paths_to_append_rel
6b94e7a6d did this for ordered append paths to allow fast startup
MergeAppends, however, nothing was done for the Append case.
Here we adjust add_paths_to_append_rel() to have it build an AppendPath
containing the cheapest startup paths from each of the child relations
when the append rel has "consider_startup" set.
Author: Andy Fan, David Rowley
Discussion: https://www.postgresql.org/message-id/CAKU4AWrXSkUV=Pt-gRxQT7EbfUeNssprGyNsB=5mJibFZ6S3ww@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r-- | src/backend/optimizer/path/allpaths.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index b11b9399891..40129016260 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -1307,6 +1307,8 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, { List *subpaths = NIL; bool subpaths_valid = true; + List *startup_subpaths = NIL; + bool startup_subpaths_valid = true; List *partial_subpaths = NIL; List *pa_partial_subpaths = NIL; List *pa_nonpartial_subpaths = NIL; @@ -1346,6 +1348,20 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, else subpaths_valid = false; + /* + * When the planner is considering cheap startup plans, we'll also + * collect all the cheapest_startup_paths and build an AppendPath + * containing those as subpaths. + */ + if (rel->consider_startup && childrel->pathlist != NIL && + childrel->cheapest_startup_path->param_info == NULL) + accumulate_append_subpath(childrel->cheapest_startup_path, + &startup_subpaths, + NULL); + else + startup_subpaths_valid = false; + + /* Same idea, but for a partial plan. */ if (childrel->partial_pathlist != NIL) { @@ -1478,6 +1494,11 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, NIL, NULL, 0, false, -1)); + /* build an AppendPath for the cheap startup paths, if valid */ + if (startup_subpaths_valid) + add_path(rel, (Path *) create_append_path(root, rel, startup_subpaths, + NIL, NIL, NULL, 0, false, -1)); + /* * Consider an append of unordered, unparameterized partial paths. Make * it parallel-aware if possible. |