2021-03-03 08:36:20 +00:00
|
|
|
drop table if exists x;
|
|
|
|
|
|
|
|
create table x (i int, j int) engine MergeTree partition by i order by j settings index_granularity = 1;
|
|
|
|
|
|
|
|
insert into x values (1, 1), (1, 2), (1, 3), (2, 4), (2, 5), (2, 6);
|
|
|
|
|
|
|
|
set max_rows_to_read = 3;
|
|
|
|
|
2021-03-09 12:09:35 +00:00
|
|
|
select * from x where _partition_id = partitionId(1);
|
2021-03-03 08:36:20 +00:00
|
|
|
|
2021-12-09 17:15:11 +00:00
|
|
|
set max_rows_to_read = 5; -- one row for subquery + subquery
|
2021-03-03 08:36:20 +00:00
|
|
|
|
2021-03-09 12:09:35 +00:00
|
|
|
select * from x where _partition_id in (select partitionId(number + 1) from numbers(1));
|
2021-03-03 08:36:20 +00:00
|
|
|
|
|
|
|
-- trivial count optimization test
|
2021-12-09 17:15:11 +00:00
|
|
|
set max_rows_to_read = 2; -- one row for subquery + subquery itself
|
2022-02-02 18:31:45 +00:00
|
|
|
-- TODO: Relax the limits because we might build prepared set twice with _minmax_count_projection
|
|
|
|
set max_rows_to_read = 3;
|
2021-03-09 12:09:35 +00:00
|
|
|
select count() from x where _partition_id in (select partitionId(number + 1) from numbers(1));
|
2021-03-03 08:36:20 +00:00
|
|
|
|
|
|
|
drop table x;
|
2021-04-20 14:53:17 +00:00
|
|
|
|
|
|
|
drop table if exists mt;
|
|
|
|
|
|
|
|
create table mt (n UInt64) engine=MergeTree order by n partition by n % 10;
|
|
|
|
|
|
|
|
set max_rows_to_read = 200;
|
|
|
|
|
|
|
|
insert into mt select * from numbers(100);
|
|
|
|
|
|
|
|
select * from mt where toUInt64(substr(_part, 1, position(_part, '_') - 1)) = 1;
|
|
|
|
|
|
|
|
drop table mt;
|