Skip to content

Commit c759395

Browse files
committed
Code review for Parallel Append.
- Remove unnecessary #include mistakenly added in execnodes.h. - Fix mistake in comment in choose_next_subplan_for_leader. - Adjust row estimates in cost_append for a possibly-different parallel divisor. - Clamp row estimates in cost_append after operations that may not produce integers. Amit Kapila, with cosmetic adjustments by me. Discussion: http://postgr.es/m/CAA4eK1+qcbeai3coPpRW=GFCzFeLUsuY4T-AKHqMjxpEGZBPQg@mail.gmail.com
1 parent 934c798 commit c759395

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/backend/executor/nodeAppend.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,9 @@ choose_next_subplan_for_leader(AppendState *node)
446446
*
447447
* We start from the first plan and advance through the list;
448448
* when we get back to the end, we loop back to the first
449-
* nonpartial plan. This assigns the non-partial plans first
450-
* in order of descending cost and then spreads out the
451-
* workers as evenly as possible across the remaining partial
452-
* plans.
449+
* partial plan. This assigns the non-partial plans first in
450+
* order of descending cost and then spreads out the workers
451+
* as evenly as possible across the remaining partial plans.
453452
* ----------------------------------------------------------------
454453
*/
455454
static bool

src/backend/optimizer/path/costsize.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,18 +1883,26 @@ cost_append(AppendPath *apath)
18831883
subpath->startup_cost);
18841884

18851885
/*
1886-
* Apply parallel divisor to non-partial subpaths. Also add the
1887-
* cost of partial paths to the total cost, but ignore non-partial
1888-
* paths for now.
1886+
* Apply parallel divisor to subpaths. Scale the number of rows
1887+
* for each partial subpath based on the ratio of the parallel
1888+
* divisor originally used for the subpath to the one we adopted.
1889+
* Also add the cost of partial paths to the total cost, but
1890+
* ignore non-partial paths for now.
18891891
*/
18901892
if (i < apath->first_partial_path)
18911893
apath->path.rows += subpath->rows / parallel_divisor;
18921894
else
18931895
{
1894-
apath->path.rows += subpath->rows;
1896+
double subpath_parallel_divisor;
1897+
1898+
subpath_parallel_divisor = get_parallel_divisor(subpath);
1899+
apath->path.rows += subpath->rows * (subpath_parallel_divisor /
1900+
parallel_divisor);
18951901
apath->path.total_cost += subpath->total_cost;
18961902
}
18971903

1904+
apath->path.rows = clamp_row_est(apath->path.rows);
1905+
18981906
i++;
18991907
}
19001908

src/include/nodes/execnodes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "lib/pairingheap.h"
2222
#include "nodes/params.h"
2323
#include "nodes/plannodes.h"
24-
#include "storage/spin.h"
2524
#include "utils/hsearch.h"
2625
#include "utils/queryenvironment.h"
2726
#include "utils/reltrigger.h"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy