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

Appearance settings

Commit 3b1a7eb

Browse filesBrowse files
committed
Don't zero tuple_fraction when planning UNIONs with ORDER BYs
Since 66c0185, the planner is able to use Merge Append -> Unique to implement UNION queries and each subquery is prompted to produce Paths correctly sorted by the UNION's targetlist. Here we remove some now redundant code which was zeroing the tuple_fraction at the parent level. This will allow the planner to consider cheap startup paths when planning the UNION's subqueries. EXCEPT and INTERSECT set operations still have the tuple_fraction zeroed in generate_nonunion_paths(). These operations currently always read all of their subqueries' tuples. Reported-by: Tom Lane Discussion: https://postgr.es/m/3703023.1711654574@sss.pgh.pa.us
1 parent 06c418e commit 3b1a7eb
Copy full SHA for 3b1a7eb

File tree

Expand file treeCollapse file tree

1 file changed

+0
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+0
-11
lines changed

‎src/backend/optimizer/plan/planner.c

Copy file name to clipboardExpand all lines: src/backend/optimizer/plan/planner.c
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,17 +1338,6 @@ grouping_planner(PlannerInfo *root, double tuple_fraction,
13381338

13391339
if (parse->setOperations)
13401340
{
1341-
/*
1342-
* If there's a top-level ORDER BY, assume we have to fetch all the
1343-
* tuples. This might be too simplistic given all the hackery below
1344-
* to possibly avoid the sort; but the odds of accurate estimates here
1345-
* are pretty low anyway. XXX try to get rid of this in favor of
1346-
* letting plan_set_operations generate both fast-start and
1347-
* cheapest-total paths.
1348-
*/
1349-
if (parse->sortClause)
1350-
root->tuple_fraction = 0.0;
1351-
13521341
/*
13531342
* Construct Paths for set operations. The results will not need any
13541343
* work except perhaps a top-level sort and/or LIMIT. Note that any

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.