1
1
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
2
- index 18a5af6b91..18c2ed3bfd 100644
2
+ index 19ffcc2cacb..93934d42e30 100644
3
3
--- a/src/backend/commands/explain.c
4
4
+++ b/src/backend/commands/explain.c
5
- @@ -25 ,6 +25 ,7 @@
5
+ @@ -27 ,6 +27 ,7 @@
6
6
#include "nodes/extensible.h"
7
7
#include "nodes/makefuncs.h"
8
8
#include "nodes/nodeFuncs.h"
9
9
+ #include "optimizer/cost.h"
10
10
#include "parser/analyze.h"
11
11
#include "parser/parsetree.h"
12
12
#include "rewrite/rewriteHandler.h"
13
- @@ -48 ,6 +49 ,12 @@ ExplainOneQuery_hook_type ExplainOneQuery_hook = NULL;
13
+ @@ -50 ,6 +51 ,12 @@ ExplainOneQuery_hook_type ExplainOneQuery_hook = NULL;
14
14
/* Hook for plugins to get control in explain_get_index_name() */
15
15
explain_get_index_name_hook_type explain_get_index_name_hook = NULL;
16
16
@@ -21,9 +21,9 @@ index 18a5af6b91..18c2ed3bfd 100644
21
21
+ ExplainOneNode_hook_type ExplainOneNode_hook = NULL;
22
22
+
23
23
24
- /* Instrumentation data for SERIALIZE option */
25
- typedef struct SerializeMetrics
26
- @@ -805 ,6 +812 ,10 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es ,
24
+ /*
25
+ * Various places within need to convert bytes to kilobytes. Round these up
26
+ @@ -815 ,6 +822 ,10 @@ ExplainOnePlan(PlannedStmt *plannedstmt, CachedPlan *cplan ,
27
27
ExplainPropertyFloat("Execution Time", "ms", 1000.0 * totaltime, 3,
28
28
es);
29
29
@@ -34,7 +34,7 @@ index 18a5af6b91..18c2ed3bfd 100644
34
34
ExplainCloseGroup("Query", NULL, true, es);
35
35
}
36
36
37
- @@ -2001 ,6 +2012 ,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
37
+ @@ -2009 ,6 +2020 ,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
38
38
}
39
39
}
40
40
@@ -45,7 +45,7 @@ index 18a5af6b91..18c2ed3bfd 100644
45
45
if (es->format == EXPLAIN_FORMAT_TEXT)
46
46
appendStringInfoChar(es->str, '\n');
47
47
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
48
- index 2bb6db1df7..ac95740598 100644
48
+ index 256568d05a2..914f6124e67 100644
49
49
--- a/src/backend/optimizer/path/costsize.c
50
50
+++ b/src/backend/optimizer/path/costsize.c
51
51
@@ -109,6 +109,11 @@
@@ -68,7 +68,7 @@ index 2bb6db1df7..ac95740598 100644
68
68
69
69
70
70
/*
71
- @@ -5309 ,6 +5313 ,58 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
71
+ @@ -5318 ,6 +5322 ,58 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
72
72
}
73
73
74
74
@@ -127,7 +127,7 @@ index 2bb6db1df7..ac95740598 100644
127
127
/*
128
128
* set_baserel_size_estimates
129
129
* Set the size estimates for the given base relation.
130
- @@ -5325 ,19 +5381 ,10 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
130
+ @@ -5334 ,19 +5390 ,10 @@ approx_tuple_count(PlannerInfo *root, JoinPath *path, List *quals)
131
131
void
132
132
set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
133
133
{
@@ -148,7 +148,7 @@ index 2bb6db1df7..ac95740598 100644
148
148
149
149
cost_qual_eval(&rel->baserestrictcost, rel->baserestrictinfo, root);
150
150
151
- @@ -5348 ,13 +5395 ,33 @@ set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
151
+ @@ -5357 ,13 +5404 ,33 @@ set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
152
152
* get_parameterized_baserel_size
153
153
* Make a size estimate for a parameterized scan of a base relation.
154
154
*
@@ -184,7 +184,7 @@ index 2bb6db1df7..ac95740598 100644
184
184
{
185
185
List *allclauses;
186
186
double nrows;
187
- @@ -5383 ,6 +5450 ,36 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
187
+ @@ -5392 ,6 +5459 ,36 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
188
188
* set_joinrel_size_estimates
189
189
* Set the size estimates for the given join relation.
190
190
*
@@ -221,7 +221,7 @@ index 2bb6db1df7..ac95740598 100644
221
221
* The rel's targetlist must have been constructed already, and a
222
222
* restriction clause list that matches the given component rels must
223
223
* be provided.
224
- @@ -5402 ,11 +5499 ,11 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
224
+ @@ -5411 ,11 +5508 ,11 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel,
225
225
* build_joinrel_tlist, and baserestrictcost is not used for join rels.
226
226
*/
227
227
void
@@ -238,7 +238,7 @@ index 2bb6db1df7..ac95740598 100644
238
238
{
239
239
rel->rows = calc_joinrel_size_estimate(root,
240
240
rel,
241
- @@ -5422 ,6 +5519 ,35 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
241
+ @@ -5431 ,6 +5528 ,35 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
242
242
* get_parameterized_joinrel_size
243
243
* Make a size estimate for a parameterized scan of a join relation.
244
244
*
@@ -274,7 +274,7 @@ index 2bb6db1df7..ac95740598 100644
274
274
* 'rel' is the joinrel under consideration.
275
275
* 'outer_path', 'inner_path' are (probably also parameterized) Paths that
276
276
* produce the relations being joined.
277
- @@ -5434 ,11 +5560 ,11 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
277
+ @@ -5443 ,11 +5569 ,11 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
278
278
* set_joinrel_size_estimates must have been applied already.
279
279
*/
280
280
double
@@ -291,7 +291,7 @@ index 2bb6db1df7..ac95740598 100644
291
291
{
292
292
double nrows;
293
293
294
- @@ -6153 ,7 +6279 ,7 @@ set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
294
+ @@ -6162 ,7 +6288 ,7 @@ set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
295
295
/* Should only be applied to base relations */
296
296
Assert(rel->relid > 0);
297
297
@@ -300,7 +300,7 @@ index 2bb6db1df7..ac95740598 100644
300
300
301
301
cost_qual_eval(&rel->baserestrictcost, rel->baserestrictinfo, root);
302
302
303
- @@ -6446 ,7 +6572 ,7 @@ page_size(double tuples, int width)
303
+ @@ -6455 ,7 +6581 ,7 @@ page_size(double tuples, int width)
304
304
* Estimate the fraction of the work that each worker will do given the
305
305
* number of workers budgeted for the path.
306
306
*/
@@ -310,7 +310,7 @@ index 2bb6db1df7..ac95740598 100644
310
310
{
311
311
double parallel_divisor = path->parallel_workers;
312
312
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
313
- index c13586c537..2f889570de 100644
313
+ index 75e2b0b9036..8641c0c594a 100644
314
314
--- a/src/backend/optimizer/plan/createplan.c
315
315
+++ b/src/backend/optimizer/plan/createplan.c
316
316
@@ -72,6 +72,7 @@
@@ -321,7 +321,7 @@ index c13586c537..2f889570de 100644
321
321
322
322
static Plan *create_plan_recurse(PlannerInfo *root, Path *best_path,
323
323
int flags);
324
- @@ -551 ,6 +552 ,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
324
+ @@ -548 ,6 +549 ,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
325
325
break;
326
326
}
327
327
@@ -332,7 +332,7 @@ index c13586c537..2f889570de 100644
332
332
return plan;
333
333
}
334
334
335
- @@ -5458 ,6 +5463 ,7 @@ copy_generic_path_info(Plan *dest, Path *src)
335
+ @@ -5451 ,6 +5456 ,7 @@ copy_generic_path_info(Plan *dest, Path *src)
336
336
dest->plan_width = src->pathtarget->width;
337
337
dest->parallel_aware = src->parallel_aware;
338
338
dest->parallel_safe = src->parallel_safe;
@@ -341,10 +341,10 @@ index c13586c537..2f889570de 100644
341
341
342
342
/*
343
343
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
344
- index 0f423e9684..8cd228baa1 100644
344
+ index a4d523dcb0f..ed5cd3651f5 100644
345
345
--- a/src/backend/optimizer/plan/planner.c
346
346
+++ b/src/backend/optimizer/plan/planner.c
347
- @@ -144 ,7 +144 ,8 @@ static List *extract_rollup_sets(List *groupingSets);
347
+ @@ -143 ,7 +143 ,8 @@ static List *extract_rollup_sets(List *groupingSets);
348
348
static List *reorder_grouping_sets(List *groupingSets, List *sortclause);
349
349
static void standard_qp_callback(PlannerInfo *root, void *extra);
350
350
static double get_number_of_groups(PlannerInfo *root,
@@ -354,7 +354,7 @@ index 0f423e9684..8cd228baa1 100644
354
354
grouping_sets_data *gd,
355
355
List *target_list);
356
356
static RelOptInfo *create_grouping_paths(PlannerInfo *root,
357
- @@ -3697 ,7 +3698 ,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
357
+ @@ -3552 ,7 +3553 ,8 @@ standard_qp_callback(PlannerInfo *root, void *extra)
358
358
*/
359
359
static double
360
360
get_number_of_groups(PlannerInfo *root,
@@ -364,7 +364,7 @@ index 0f423e9684..8cd228baa1 100644
364
364
grouping_sets_data *gd,
365
365
List *target_list)
366
366
{
367
- @@ -3734 ,7 +3736 ,7 @@ get_number_of_groups(PlannerInfo *root,
367
+ @@ -3589 ,7 +3591 ,7 @@ get_number_of_groups(PlannerInfo *root,
368
368
GroupingSetData *gs = lfirst_node(GroupingSetData, lc3);
369
369
double numGroups = estimate_num_groups(root,
370
370
groupExprs,
@@ -373,7 +373,7 @@ index 0f423e9684..8cd228baa1 100644
373
373
&gset,
374
374
NULL);
375
375
376
- @@ -3760 ,7 +3762 ,7 @@ get_number_of_groups(PlannerInfo *root,
376
+ @@ -3615 ,7 +3617 ,7 @@ get_number_of_groups(PlannerInfo *root,
377
377
GroupingSetData *gs = lfirst_node(GroupingSetData, lc2);
378
378
double numGroups = estimate_num_groups(root,
379
379
groupExprs,
@@ -382,7 +382,7 @@ index 0f423e9684..8cd228baa1 100644
382
382
&gset,
383
383
NULL);
384
384
385
- @@ -3777 ,8 +3779 ,8 @@ get_number_of_groups(PlannerInfo *root,
385
+ @@ -3632 ,8 +3634 ,8 @@ get_number_of_groups(PlannerInfo *root,
386
386
groupExprs = get_sortgrouplist_exprs(root->processed_groupClause,
387
387
target_list);
388
388
@@ -393,7 +393,7 @@ index 0f423e9684..8cd228baa1 100644
393
393
}
394
394
}
395
395
else if (parse->groupingSets)
396
- @@ -4168 ,7 +4170 ,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
396
+ @@ -4024 ,7 +4026 ,8 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
397
397
* Estimate number of groups.
398
398
*/
399
399
dNumGroups = get_number_of_groups(root,
@@ -403,7 +403,7 @@ index 0f423e9684..8cd228baa1 100644
403
403
gd,
404
404
extra->targetList);
405
405
406
- @@ -7405 ,13 +7408 ,15 @@ create_partial_grouping_paths(PlannerInfo *root,
406
+ @@ -7308 ,13 +7311 ,15 @@ create_partial_grouping_paths(PlannerInfo *root,
407
407
if (cheapest_total_path != NULL)
408
408
dNumPartialGroups =
409
409
get_number_of_groups(root,
@@ -422,7 +422,7 @@ index 0f423e9684..8cd228baa1 100644
422
422
extra->targetList);
423
423
424
424
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
425
- index d7266e4cdb..7e5b771d9f 100644
425
+ index ff507331a06..068b63b9b47 100644
426
426
--- a/src/backend/optimizer/util/relnode.c
427
427
+++ b/src/backend/optimizer/util/relnode.c
428
428
@@ -286,6 +286,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent)
@@ -488,18 +488,18 @@ index d7266e4cdb..7e5b771d9f 100644
488
488
489
489
return ppi;
490
490
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
491
- index 08fa6774d9..034b434773 100644
491
+ index 5b35debc8ff..06a7bebe4f8 100644
492
492
--- a/src/backend/utils/adt/selfuncs.c
493
493
+++ b/src/backend/utils/adt/selfuncs.c
494
- @@ -146 ,6 +146 ,7 @@
494
+ @@ -147 ,6 +147 ,7 @@
495
495
/* Hooks for plugins to get control when we ask for stats */
496
496
get_relation_stats_hook_type get_relation_stats_hook = NULL;
497
497
get_index_stats_hook_type get_index_stats_hook = NULL;
498
498
+ estimate_num_groups_hook_type estimate_num_groups_hook = NULL;
499
499
500
500
static double eqsel_internal(PG_FUNCTION_ARGS, bool negate);
501
501
static double eqjoinsel_inner(Oid opfuncoid, Oid collation,
502
- @@ -3345 ,6 +3346 ,20 @@ add_unique_group_var(PlannerInfo *root, List *varinfos,
502
+ @@ -3355 ,6 +3356 ,20 @@ add_unique_group_var(PlannerInfo *root, List *varinfos,
503
503
return varinfos;
504
504
}
505
505
@@ -521,7 +521,7 @@ index 08fa6774d9..034b434773 100644
521
521
* estimate_num_groups - Estimate number of groups in a grouped query
522
522
*
523
523
diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h
524
- index 3ab0aae78f..5a257cdb0a 100644
524
+ index 64547bd9b9c..74792f1a8cf 100644
525
525
--- a/src/include/commands/explain.h
526
526
+++ b/src/include/commands/explain.h
527
527
@@ -87,6 +87,18 @@ extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
@@ -544,10 +544,10 @@ index 3ab0aae78f..5a257cdb0a 100644
544
544
extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
545
545
ParamListInfo params, DestReceiver *dest);
546
546
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
547
- index 07e2415398..1413fbf03c 100644
547
+ index fbf05322c75..8fcb1fadda6 100644
548
548
--- a/src/include/nodes/pathnodes.h
549
549
+++ b/src/include/nodes/pathnodes.h
550
- @@ -1049 ,6 +1049 ,16 @@ typedef struct RelOptInfo
550
+ @@ -1073 ,6 +1073 ,16 @@ typedef struct RelOptInfo
551
551
List **partexprs pg_node_attr(read_write_ignore);
552
552
/* Nullable partition key expressions */
553
553
List **nullable_partexprs pg_node_attr(read_write_ignore);
@@ -564,7 +564,7 @@ index 07e2415398..1413fbf03c 100644
564
564
} RelOptInfo;
565
565
566
566
/*
567
- @@ -1586 ,6 +1596 ,10 @@ typedef struct ParamPathInfo
567
+ @@ -1615 ,6 +1625 ,10 @@ typedef struct ParamPathInfo
568
568
Cardinality ppi_rows; /* estimated number of result tuples */
569
569
List *ppi_clauses; /* join clauses available from outer rels */
570
570
Bitmapset *ppi_serials; /* set of rinfo_serial for enforced quals */
@@ -576,10 +576,10 @@ index 07e2415398..1413fbf03c 100644
576
576
577
577
578
578
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
579
- index 62cd6a6666..bb47a51ba7 100644
579
+ index 22841211f48..7a247fa8de8 100644
580
580
--- a/src/include/nodes/plannodes.h
581
581
+++ b/src/include/nodes/plannodes.h
582
- @@ -170 ,6 +170 ,9 @@ typedef struct Plan
582
+ @@ -218 ,6 +218 ,9 @@ typedef struct Plan
583
583
*/
584
584
Bitmapset *extParam;
585
585
Bitmapset *allParam;
@@ -590,7 +590,7 @@ index 62cd6a6666..bb47a51ba7 100644
590
590
591
591
/* ----------------
592
592
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
593
- index 854a782944..9e8cde176f 100644
593
+ index 3aa3c16e442..cf39af9a974 100644
594
594
--- a/src/include/optimizer/cost.h
595
595
+++ b/src/include/optimizer/cost.h
596
596
@@ -41,6 +41,37 @@ typedef enum
@@ -674,7 +674,7 @@ index 854a782944..9e8cde176f 100644
674
674
675
675
#endif /* COST_H */
676
676
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
677
- index 1035e6560c..27e42b2679 100644
677
+ index 719be3897f6..dddc76fcefd 100644
678
678
--- a/src/include/optimizer/pathnode.h
679
679
+++ b/src/include/optimizer/pathnode.h
680
680
@@ -18,6 +18,10 @@
@@ -689,10 +689,10 @@ index 1035e6560c..27e42b2679 100644
689
689
* prototypes for pathnode.c
690
690
*/
691
691
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
692
- index 93137261e4..0621c27595 100644
692
+ index 5a930199611..69d4668b801 100644
693
693
--- a/src/include/optimizer/planmain.h
694
694
+++ b/src/include/optimizer/planmain.h
695
- @@ -24 ,6 +24 ,12 @@ extern PGDLLIMPORT double cursor_tuple_fraction ;
695
+ @@ -25 ,6 +25 ,12 @@ extern PGDLLIMPORT bool enable_self_join_elimination ;
696
696
/* query_planner callback to compute query_pathkeys */
697
697
typedef void (*query_pathkeys_callback) (PlannerInfo *root, void *extra);
698
698
@@ -706,10 +706,10 @@ index 93137261e4..0621c27595 100644
706
706
* prototypes for plan/planmain.c
707
707
*/
708
708
diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h
709
- index f2563ad1cb..0beac5f313 100644
709
+ index 82ac8c6d9da..bc168ff691d 100644
710
710
--- a/src/include/utils/selfuncs.h
711
711
+++ b/src/include/utils/selfuncs.h
712
- @@ -147 ,6 +147 ,13 @@ typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
712
+ @@ -148 ,6 +148 ,13 @@ typedef bool (*get_index_stats_hook_type) (PlannerInfo *root,
713
713
AttrNumber indexattnum,
714
714
VariableStatData *vardata);
715
715
extern PGDLLIMPORT get_index_stats_hook_type get_index_stats_hook;
@@ -723,7 +723,7 @@ index f2563ad1cb..0beac5f313 100644
723
723
724
724
/* Functions in selfuncs.c */
725
725
726
- @@ -213 ,6 +220 ,9 @@ extern void mergejoinscansel(PlannerInfo *root, Node *clause,
726
+ @@ -214 ,6 +221 ,9 @@ extern void mergejoinscansel(PlannerInfo *root, Node *clause,
727
727
Selectivity *leftstart, Selectivity *leftend,
728
728
Selectivity *rightstart, Selectivity *rightend);
729
729
0 commit comments