30000000000
millions
50
100
window
10
1000
10000
create table sorted_{millions}m engine MergeTree order by k as select number % 100 k, rand() v from numbers_mt(1000000 * {millions})
optimize table sorted_{millions}m final
select k, groupArraySorted({window})(v) from sorted_{millions}m group by k format Null
select k % 10 kk, groupArraySorted({window})(v) from sorted_{millions}m group by kk format Null
drop table if exists sorted_{millions}m