forked from timescale/timescaledb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chunk-wise agg: add GatherMerge above Sort (timescale#7547)
Currently we would add a Gather just above Append of partial aggregates and below Sort, which doesn't allow us to paralellize the Sort itself. Disable-check: force-changelog-file
- Loading branch information
Showing
4 changed files
with
158 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
-- This file and its contents are licensed under the Timescale License. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-TIMESCALE for a copy of the license. | ||
-- Exercise the GatherMerge -> Sort -> Append -> Partial Aggregate plan. | ||
\set prefix 'explain (costs off, timing off, summary off)' | ||
set parallel_setup_cost = 0; | ||
set parallel_tuple_cost = 0; | ||
set max_parallel_workers_per_gather = 2; | ||
set parallel_leader_participation = off; | ||
set enable_hashagg to off; | ||
:prefix | ||
select count(*) from metrics group by v0; | ||
QUERY PLAN | ||
Finalize GroupAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Gather Merge | ||
Workers Planned: 2 | ||
-> Sort | ||
Sort Key: _hyper_X_X_chunk.v0 | ||
-> Parallel Append | ||
-> Partial GroupAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Sort | ||
Sort Key: _hyper_X_X_chunk.v0 | ||
-> Seq Scan on _hyper_X_X_chunk | ||
-> Partial GroupAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Sort | ||
Sort Key: _hyper_X_X_chunk.v0 | ||
-> Seq Scan on _hyper_X_X_chunk | ||
-> Partial GroupAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Sort | ||
Sort Key: _hyper_X_X_chunk.v0 | ||
-> Seq Scan on _hyper_X_X_chunk | ||
(22 rows) | ||
|
||
reset enable_hashagg; | ||
:prefix | ||
select count(*) from metrics group by v0; | ||
QUERY PLAN | ||
Finalize HashAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Gather | ||
Workers Planned: 2 | ||
-> Parallel Append | ||
-> Partial HashAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Seq Scan on _hyper_X_X_chunk | ||
-> Partial HashAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Seq Scan on _hyper_X_X_chunk | ||
-> Partial HashAggregate | ||
Group Key: _hyper_X_X_chunk.v0 | ||
-> Seq Scan on _hyper_X_X_chunk | ||
(14 rows) | ||
|
||
reset parallel_setup_cost; | ||
reset parallel_tuple_cost; | ||
reset max_parallel_workers_per_gather; | ||
reset parallel_leader_participation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- This file and its contents are licensed under the Timescale License. | ||
-- Please see the included NOTICE for copyright information and | ||
-- LICENSE-TIMESCALE for a copy of the license. | ||
|
||
-- Exercise the GatherMerge -> Sort -> Append -> Partial Aggregate plan. | ||
|
||
\set prefix 'explain (costs off, timing off, summary off)' | ||
|
||
set parallel_setup_cost = 0; | ||
set parallel_tuple_cost = 0; | ||
set max_parallel_workers_per_gather = 2; | ||
set parallel_leader_participation = off; | ||
|
||
set enable_hashagg to off; | ||
|
||
:prefix | ||
select count(*) from metrics group by v0; | ||
|
||
reset enable_hashagg; | ||
|
||
:prefix | ||
select count(*) from metrics group by v0; | ||
|
||
reset parallel_setup_cost; | ||
reset parallel_tuple_cost; | ||
reset max_parallel_workers_per_gather; | ||
reset parallel_leader_participation; |