@@ -57,24 +57,47 @@ index e81b990092..157f6e2721 100644
57
57
else
58
58
{
59
59
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
60
- index bd87f23784..d0a87fc57e 100644
60
+ index bd87f23784..f4d567b8ac 100644
61
61
--- a/src/backend/nodes/copyfuncs.c
62
62
+++ b/src/backend/nodes/copyfuncs.c
63
- @@ -127,6 +127,12 @@ CopyPlanFields(const Plan *from, Plan *newnode)
64
- COPY_NODE_FIELD(lefttree);
65
- COPY_NODE_FIELD(righttree);
63
+ @@ -129,6 +129,7 @@ CopyPlanFields(const Plan *from, Plan *newnode)
66
64
COPY_NODE_FIELD(initPlan);
67
- + COPY_SCALAR_FIELD(had_path);
68
- + COPY_NODE_FIELD(path_clauses);
69
- + COPY_NODE_FIELD(path_relids);
70
- + COPY_SCALAR_FIELD(path_jointype);
71
- + COPY_SCALAR_FIELD(path_parallel_workers);
72
- + COPY_SCALAR_FIELD(was_parametrized);
73
65
COPY_BITMAPSET_FIELD(extParam);
74
66
COPY_BITMAPSET_FIELD(allParam);
67
+ + COPY_NODE_FIELD(private);
75
68
}
69
+
70
+ /*
71
+ diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
72
+ index e32b92e299..53b6188ff3 100644
73
+ --- a/src/backend/nodes/outfuncs.c
74
+ +++ b/src/backend/nodes/outfuncs.c
75
+ @@ -342,6 +342,7 @@ _outPlanInfo(StringInfo str, const Plan *node)
76
+ WRITE_NODE_FIELD(initPlan);
77
+ WRITE_BITMAPSET_FIELD(extParam);
78
+ WRITE_BITMAPSET_FIELD(allParam);
79
+ + /*WRITE_NODE_FIELD(private); */
80
+ }
81
+
82
+ /*
83
+ diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
84
+ index f0b34ecfac..cf6dfd37f9 100644
85
+ --- a/src/backend/nodes/readfuncs.c
86
+ +++ b/src/backend/nodes/readfuncs.c
87
+ @@ -1628,6 +1628,11 @@ ReadCommonPlan(Plan *local_node)
88
+ READ_NODE_FIELD(initPlan);
89
+ READ_BITMAPSET_FIELD(extParam);
90
+ READ_BITMAPSET_FIELD(allParam);
91
+ + local_node->private = NIL;
92
+ + /* READ_NODE_FIELD(private);
93
+ + * Don't serialize this field. It is required to serialize RestrictInfo and
94
+ + * EqualenceClass.
95
+ + */
96
+ }
97
+
98
+ /*
76
99
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
77
- index 8577c7b138..02e59233e2 100644
100
+ index 8577c7b138..bf7c625537 100644
78
101
--- a/src/backend/optimizer/path/costsize.c
79
102
+++ b/src/backend/optimizer/path/costsize.c
80
103
@@ -98,6 +98,11 @@
@@ -97,87 +120,6 @@ index 8577c7b138..02e59233e2 100644
97
120
98
121
99
122
/*
100
- @@ -269,7 +273,7 @@ cost_seqscan(Path *path, PlannerInfo *root,
101
- /* Adjust costing for parallelism, if used. */
102
- if (path->parallel_workers > 0)
103
- {
104
- - double parallel_divisor = get_parallel_divisor(path);
105
- + double parallel_divisor = get_parallel_divisor(path->parallel_workers);
106
-
107
- /* The CPU cost is divided among all the workers. */
108
- cpu_run_cost /= parallel_divisor;
109
- @@ -748,7 +752,7 @@ cost_index(IndexPath *path, PlannerInfo *root, double loop_count,
110
- /* Adjust costing for parallelism, if used. */
111
- if (path->path.parallel_workers > 0)
112
- {
113
- - double parallel_divisor = get_parallel_divisor(&path->path);
114
- + double parallel_divisor = get_parallel_divisor(path->path.parallel_workers);
115
-
116
- path->path.rows = clamp_row_est(path->path.rows / parallel_divisor);
117
-
118
- @@ -1029,7 +1033,7 @@ cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
119
- /* Adjust costing for parallelism, if used. */
120
- if (path->parallel_workers > 0)
121
- {
122
- - double parallel_divisor = get_parallel_divisor(path);
123
- + double parallel_divisor = get_parallel_divisor(path->parallel_workers);
124
-
125
- /* The CPU cost is divided among all the workers. */
126
- cpu_run_cost /= parallel_divisor;
127
- @@ -2228,7 +2232,7 @@ cost_append(AppendPath *apath)
128
- else /* parallel-aware */
129
- {
130
- int i = 0;
131
- - double parallel_divisor = get_parallel_divisor(&apath->path);
132
- + double parallel_divisor = get_parallel_divisor(apath->path.parallel_workers);
133
-
134
- /* Parallel-aware Append never produces ordered output. */
135
- Assert(apath->path.pathkeys == NIL);
136
- @@ -2262,7 +2266,7 @@ cost_append(AppendPath *apath)
137
- {
138
- double subpath_parallel_divisor;
139
-
140
- - subpath_parallel_divisor = get_parallel_divisor(subpath);
141
- + subpath_parallel_divisor = get_parallel_divisor(subpath->parallel_workers);
142
- apath->path.rows += subpath->rows * (subpath_parallel_divisor /
143
- parallel_divisor);
144
- apath->path.total_cost += subpath->total_cost;
145
- @@ -3002,7 +3006,7 @@ final_cost_nestloop(PlannerInfo *root, NestPath *path,
146
- /* For partial paths, scale row estimate. */
147
- if (path->path.parallel_workers > 0)
148
- {
149
- - double parallel_divisor = get_parallel_divisor(&path->path);
150
- + double parallel_divisor = get_parallel_divisor(path->path.parallel_workers);
151
-
152
- path->path.rows =
153
- clamp_row_est(path->path.rows / parallel_divisor);
154
- @@ -3448,7 +3452,7 @@ final_cost_mergejoin(PlannerInfo *root, MergePath *path,
155
- /* For partial paths, scale row estimate. */
156
- if (path->jpath.path.parallel_workers > 0)
157
- {
158
- - double parallel_divisor = get_parallel_divisor(&path->jpath.path);
159
- + double parallel_divisor = get_parallel_divisor(path->jpath.path.parallel_workers);
160
-
161
- path->jpath.path.rows =
162
- clamp_row_est(path->jpath.path.rows / parallel_divisor);
163
- @@ -3782,7 +3786,7 @@ initial_cost_hashjoin(PlannerInfo *root, JoinCostWorkspace *workspace,
164
- * number, so we need to undo the division.
165
- */
166
- if (parallel_hash)
167
- - inner_path_rows_total *= get_parallel_divisor(inner_path);
168
- + inner_path_rows_total *= get_parallel_divisor(inner_path->parallel_workers);
169
-
170
- /*
171
- * Get hash table size that executor would use for inner relation.
172
- @@ -3879,7 +3883,7 @@ final_cost_hashjoin(PlannerInfo *root, HashPath *path,
173
- /* For partial paths, scale row estimate. */
174
- if (path->jpath.path.parallel_workers > 0)
175
- {
176
- - double parallel_divisor = get_parallel_divisor(&path->jpath.path);
177
- + double parallel_divisor = get_parallel_divisor(path->jpath.path.parallel_workers);
178
-
179
- path->jpath.path.rows =
180
- clamp_row_est(path->jpath.path.rows / parallel_divisor);
181
123
@@ -4908,6 +4912,58 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
182
124
}
183
125
@@ -410,46 +352,17 @@ index 8577c7b138..02e59233e2 100644
410
352
411
353
cost_qual_eval(&rel->baserestrictcost, rel->baserestrictinfo, root);
412
354
413
- @@ -6035,14 +6161,25 @@ page_size(double tuples, int width)
414
- return ceil(relation_byte_size(tuples, width) / BLCKSZ);
415
- }
416
-
417
- + bool
418
- + IsParallelTuplesProcessing(const Plan *plan)
419
- + {
420
- + if (plan->path_parallel_workers > 0 && (
421
- + plan->parallel_aware || nodeTag(plan) == T_HashJoin ||
422
- + nodeTag(plan) == T_MergeJoin ||
423
- + nodeTag(plan) == T_NestLoop))
424
- + return true;
425
- + return false;
426
- + }
427
- +
428
- /*
355
+ @@ -6039,7 +6165,7 @@ page_size(double tuples, int width)
429
356
* Estimate the fraction of the work that each worker will do given the
430
357
* number of workers budgeted for the path.
431
358
*/
432
359
- static double
433
- - get_parallel_divisor(Path *path)
434
360
+ double
435
- + get_parallel_divisor(int parallel_workers )
361
+ get_parallel_divisor(Path *path )
436
362
{
437
- - double parallel_divisor = path->parallel_workers;
438
- + double parallel_divisor = parallel_workers;
439
-
440
- /*
441
- * Early experience with parallel query suggests that when there is only
442
- @@ -6059,7 +6196,7 @@ get_parallel_divisor(Path *path)
443
- {
444
- double leader_contribution;
445
-
446
- - leader_contribution = 1.0 - (0.3 * path->parallel_workers);
447
- + leader_contribution = 1.0 - (0.3 * parallel_workers);
448
- if (leader_contribution > 0)
449
- parallel_divisor += leader_contribution;
450
- }
363
+ double parallel_divisor = path->parallel_workers;
451
364
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
452
- index 439e6b6426..deadcfabb6 100644
365
+ index 439e6b6426..8dd516d8c8 100644
453
366
--- a/src/backend/optimizer/plan/createplan.c
454
367
+++ b/src/backend/optimizer/plan/createplan.c
455
368
@@ -71,6 +71,7 @@
@@ -471,6 +384,14 @@ index 439e6b6426..deadcfabb6 100644
471
384
return plan;
472
385
}
473
386
387
+ @@ -5276,6 +5281,7 @@ copy_generic_path_info(Plan *dest, Path *src)
388
+ dest->plan_width = src->pathtarget->width;
389
+ dest->parallel_aware = src->parallel_aware;
390
+ dest->parallel_safe = src->parallel_safe;
391
+ + dest->private = NIL;
392
+ }
393
+
394
+ /*
474
395
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
475
396
index e105a4d5f1..392bed5222 100644
476
397
--- a/src/backend/optimizer/util/relnode.c
@@ -556,31 +477,21 @@ index b7b2817a5d..a53b625e9e 100644
556
477
557
478
558
479
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
559
- index aaa3b65d04..bc126f8982 100644
480
+ index aaa3b65d04..5a49998c51 100644
560
481
--- a/src/include/nodes/plannodes.h
561
482
+++ b/src/include/nodes/plannodes.h
562
- @@ -145,6 +145,19 @@ typedef struct Plan
563
- List *initPlan; /* Init Plan nodes (un-correlated expr
564
- * subselects) */
565
-
566
- + /*
567
- + * information for adaptive query optimization
568
- + */
569
- + bool had_path;
570
- + List *path_clauses;
571
- + List *path_relids;
572
- + JoinType path_jointype;
573
- + int path_parallel_workers;
574
- + bool was_parametrized;
575
- + /* For Adaptive optimization DEBUG purposes */
576
- + double predicted_cardinality;
577
- + int fss_hash;
483
+ @@ -158,6 +158,9 @@ typedef struct Plan
484
+ */
485
+ Bitmapset *extParam;
486
+ Bitmapset *allParam;
578
487
+
579
- /*
580
- * Information for management of parameter-change-driven rescanning
581
- *
488
+ + /* Additional field for an extension purposes. */
489
+ + List *private;
490
+ } Plan;
491
+
492
+ /* ----------------
582
493
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
583
- index 0fe60d82e4..892b8bb7ba 100644
494
+ index 0fe60d82e4..e3198d0cc9 100644
584
495
--- a/src/include/optimizer/cost.h
585
496
+++ b/src/include/optimizer/cost.h
586
497
@@ -39,6 +39,37 @@ typedef enum
@@ -656,12 +567,11 @@ index 0fe60d82e4..892b8bb7ba 100644
656
567
extern void set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel);
657
568
extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
658
569
extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
659
- @@ -207,5 +255,7 @@ extern void set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel);
570
+ @@ -207,5 +255,6 @@ extern void set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel);
660
571
extern PathTarget *set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target);
661
572
extern double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel,
662
573
Path *bitmapqual, int loop_count, Cost *cost, double *tuple);
663
- + extern bool IsParallelTuplesProcessing(const Plan *plan);
664
- + extern double get_parallel_divisor(int parallel_workers);
574
+ + extern double get_parallel_divisor(Path *path);
665
575
666
576
#endif /* COST_H */
667
577
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
0 commit comments