mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 12:22:12 +00:00
Merge pull request #28266 from CurtizJ/fix-order-by-merge
Fix order by for `Merge` tables with `optimize_read_in_order`
This commit is contained in:
commit
4eef445df9
@ -338,9 +338,10 @@ Pipe StorageMerge::read(
|
|||||||
|
|
||||||
auto pipe = Pipe::unitePipes(std::move(pipes));
|
auto pipe = Pipe::unitePipes(std::move(pipes));
|
||||||
|
|
||||||
if (!pipe.empty())
|
if (!pipe.empty() && !query_info.input_order_info)
|
||||||
// It's possible to have many tables read from merge, resize(num_streams) might open too many files at the same time.
|
// It's possible to have many tables read from merge, resize(num_streams) might open too many files at the same time.
|
||||||
// Using narrowPipe instead.
|
// Using narrowPipe instead. But in case of reading in order of primary key, we cannot do it,
|
||||||
|
// because narrowPipe doesn't preserve order.
|
||||||
narrowPipe(pipe, num_streams);
|
narrowPipe(pipe, num_streams);
|
||||||
|
|
||||||
return pipe;
|
return pipe;
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
20
|
||||||
|
20
|
||||||
|
20
|
||||||
|
20
|
||||||
|
20
|
22
tests/queries/0_stateless/02014_storage_merge_order_by.sql
Normal file
22
tests/queries/0_stateless/02014_storage_merge_order_by.sql
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
DROP TABLE IF EXISTS short;
|
||||||
|
DROP TABLE IF EXISTS long;
|
||||||
|
DROP TABLE IF EXISTS merged;
|
||||||
|
|
||||||
|
CREATE TABLE short (e Int64, t DateTime ) ENGINE = MergeTree PARTITION BY e ORDER BY t;
|
||||||
|
CREATE TABLE long (e Int64, t DateTime ) ENGINE = MergeTree PARTITION BY (e, toStartOfMonth(t)) ORDER BY t;
|
||||||
|
|
||||||
|
insert into short select number % 11, toDateTime('2021-01-01 00:00:00') + number from numbers(1000);
|
||||||
|
insert into long select number % 11, toDateTime('2021-01-01 00:00:00') + number from numbers(1000);
|
||||||
|
|
||||||
|
CREATE TABLE merged as short ENGINE = Merge(currentDatabase(), 'short|long');
|
||||||
|
|
||||||
|
select sum(e) from (select * from merged order by t limit 10) SETTINGS optimize_read_in_order = 0;
|
||||||
|
|
||||||
|
select sum(e) from (select * from merged order by t limit 10) SETTINGS max_threads = 1;
|
||||||
|
select sum(e) from (select * from merged order by t limit 10) SETTINGS max_threads = 3;
|
||||||
|
select sum(e) from (select * from merged order by t limit 10) SETTINGS max_threads = 10;
|
||||||
|
select sum(e) from (select * from merged order by t limit 10) SETTINGS max_threads = 50;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS short;
|
||||||
|
DROP TABLE IF EXISTS long;
|
||||||
|
DROP TABLE IF EXISTS merged;
|
Loading…
Reference in New Issue
Block a user