0
256
size
100000
1000000
10000000
partitions
16
32
64
create table t_{size}_{partitions}(a UInt64) engine=MergeTree order by a partition by sipHash64(a) % {partitions}
insert into t_{size}_{partitions} select * from numbers_mt({size})
optimize table t_{size}_{partitions} final
select a from t_{size}_{partitions} group by a format Null
select a from t_{size}_{partitions} group by a format Null settings optimize_aggregation_in_order = 1
drop table t_{size}_{partitions}