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

Commit7e0ade0

Browse files
committed
Allow Gather Merge in more cases for parallel DISTINCT
Here we adjust the partial path generation for parallel DISTINCT queriesto add Sort nodes on top of any unsorted partial distinct paths.This increases the likelihood of the planner pushing a Sort below a GatherMerge which enables the final phase of the parallel distinct to beimplemented using a Unique node in more cases.Sorting the partial distinct paths is particularly useful when theDISTINCT query has an ORDER BY and LIMIT clause as this can allow cheaperplans by having the workers Hash Aggregate then Sort before feeding theresults into the Gather Merge. The non-parallel portion of the plan thenbecomes very cheap as it leaves only Unique and Limit to do in the leaderprocess.Author: Richard GuoReviewed-by: David RowleyDiscussion:https://postgr.es/m/CAMbWs48u9VoVOouJsys1qOaC9WVGVmBa+wT1dx8KvxF5GPzezA@mail.gmail.com
1 parent0b6517a commit7e0ade0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4819,7 +4819,7 @@ create_partial_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
48194819

48204820
if (partial_distinct_rel->partial_pathlist!=NIL)
48214821
{
4822-
generate_gather_paths(root,partial_distinct_rel, true);
4822+
generate_useful_gather_paths(root,partial_distinct_rel, true);
48234823
set_cheapest(partial_distinct_rel);
48244824

48254825
/*

‎src/test/regress/expected/select_distinct.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ SELECT DISTINCT four FROM tenk1;
235235
QUERY PLAN
236236
----------------------------------------------------
237237
Unique
238-
->Sort
239-
Sort Key: four
240-
->Gather
241-
Workers Planned: 2
238+
->Gather Merge
239+
Workers Planned: 2
240+
->Sort
241+
Sort Key: four
242242
-> HashAggregate
243243
Group Key: four
244244
-> Parallel Seq Scan on tenk1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp