mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-08 07:22:25 +00:00
48 lines
1.4 KiB
Plaintext
48 lines
1.4 KiB
Plaintext
-- { echoOn }
|
|
set allow_experimental_analyzer=1;
|
|
set optimize_trivial_count_query=1;
|
|
create table m3(a Int64, b UInt64) Engine=MergeTree order by tuple();
|
|
select count() from m3;
|
|
0
|
|
insert into m3 values (0,0);
|
|
insert into m3 values (-1,1);
|
|
select trimBoth(explain) from (explain select count() from m3) where explain like '%ReadFromPreparedSource (Optimized trivial count)%';
|
|
ReadFromPreparedSource (Optimized trivial count)
|
|
select count() from m3;
|
|
2
|
|
select count(*) from m3;
|
|
2
|
|
select count(a) from m3;
|
|
2
|
|
select count(b) from m3;
|
|
2
|
|
select count() + 1 from m3;
|
|
3
|
|
drop table m3;
|
|
-- checking queries with FINAL
|
|
create table replacing_m3(a Int64, b UInt64) Engine=ReplacingMergeTree() order by (a, b);
|
|
SYSTEM STOP MERGES replacing_m3;
|
|
select count() from replacing_m3;
|
|
0
|
|
insert into replacing_m3 values (0,0);
|
|
insert into replacing_m3 values (0,0);
|
|
insert into replacing_m3 values (-1,1);
|
|
insert into replacing_m3 values (-2,2);
|
|
select trimBoth(explain) from (explain select count() from replacing_m3) where explain like '%ReadFromPreparedSource (Optimized trivial count)%';
|
|
ReadFromPreparedSource (Optimized trivial count)
|
|
select count() from replacing_m3;
|
|
4
|
|
select count(*) from replacing_m3;
|
|
4
|
|
select count(a) from replacing_m3;
|
|
4
|
|
select count(b) from replacing_m3;
|
|
4
|
|
select count() from replacing_m3 FINAL;
|
|
3
|
|
select count(a) from replacing_m3 FINAL;
|
|
3
|
|
select count(b) from replacing_m3 FINAL;
|
|
3
|
|
drop table replacing_m3;
|