Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ea5eee

Browse files
author
Richard Guo
committed
Avoid creating duplicate ordered append paths
In generate_orderedappend_paths(), the function does not handle thecase where the paths in total_subpaths and fractional_subpaths areidentical. This situation is not uncommon, and as a result, it maygenerate two exactly identical ordered append paths.Fix by checking whether total_subpaths and fractional_subpaths containthe same paths, and skipping creation of the ordered append path forthe fractional case when they are identical.Given the lack of field complaints about this, I'm a bit hesitant toback-patch, but let's clean it up in HEAD.Author: Richard Guo <guofenglinux@gmail.com>Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>Discussion:https://postgr.es/m/CAMbWs4-OYsgA75tGGiBARt87G0y_z_GBTSLrzudcJxAzndYkYw@mail.gmail.com
1 parentc1777f2 commit0ea5eee

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

‎src/backend/optimizer/path/allpaths.c‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,7 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
18771877
List*total_subpaths=NIL;
18781878
List*fractional_subpaths=NIL;
18791879
boolstartup_neq_total= false;
1880+
boolfraction_neq_total= false;
18801881
boolmatch_partition_order;
18811882
boolmatch_partition_order_desc;
18821883
intend_index;
@@ -2005,15 +2006,21 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
20052006
* XXX We might consider partially sorted paths too (with an
20062007
* incremental sort on top). But we'd have to build all the
20072008
* incremental paths, do the costing etc.
2009+
*
2010+
* Also, notice whether we actually have different paths for
2011+
* the "fractional" and "total" cases. This helps avoid
2012+
* generating two identical ordered append paths.
20082013
*/
2009-
if (!cheapest_fractional)
2014+
if (cheapest_fractional==NULL)
20102015
cheapest_fractional=cheapest_total;
2016+
elseif (cheapest_fractional!=cheapest_total)
2017+
fraction_neq_total= true;
20112018
}
20122019

20132020
/*
20142021
* Notice whether we actually have different paths for the
2015-
* "cheapest" and "total" cases; frequently there will be no point
2016-
*in two create_merge_append_path() calls.
2022+
* "cheapest" and "total" cases. This helps avoid generating two
2023+
*identical ordered append paths.
20172024
*/
20182025
if (cheapest_startup!=cheapest_total)
20192026
startup_neq_total= true;
@@ -2084,7 +2091,7 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
20842091
false,
20852092
-1));
20862093

2087-
if (fractional_subpaths)
2094+
if (fractional_subpaths&&fraction_neq_total)
20882095
add_path(rel, (Path*)create_append_path(root,
20892096
rel,
20902097
fractional_subpaths,
@@ -2110,7 +2117,7 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
21102117
pathkeys,
21112118
NULL));
21122119

2113-
if (fractional_subpaths)
2120+
if (fractional_subpaths&&fraction_neq_total)
21142121
add_path(rel, (Path*)create_merge_append_path(root,
21152122
rel,
21162123
fractional_subpaths,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp