1
1
2000
10000000
8
15G
parts
100
1000
uniqs
100
10000
CREATE TABLE mt_{parts}_parts_{uniqs}_uniqs(id UInt32, val1 UInt32, val2 UInt32) ENGINE = MergeTree ORDER BY val1 PARTITION BY id % {parts} SETTINGS parts_to_throw_insert=10000, parts_to_delay_insert=10000
SYSTEM STOP MERGES mt_{parts}_parts_{uniqs}_uniqs
INSERT INTO mt_{parts}_parts_{uniqs}_uniqs SELECT number, rand() % {uniqs}, rand() FROM numbers_mt(100000000) SETTINGS max_block_size=10000000
SYSTEM START MERGES mt_{parts}_parts_{uniqs}_uniqs
OPTIMIZE TABLE mt_{parts}_parts_{uniqs}_uniqs FINAL
SELECT val2 FROM mt_{parts}_parts_10000_uniqs ORDER BY val1 LIMIT 1000000 FORMAT Null
SELECT val2 FROM mt_{parts}_parts_10000_uniqs ORDER BY val1 LIMIT 10000000 FORMAT Null
SELECT sum(val2) FROM mt_{parts}_parts_{uniqs}_uniqs GROUP BY val1 FORMAT Null
DROP TABLE IF EXISTS mt_{parts}_parts_{uniqs}_uniqs