CREATE TABLE hits_wide AS hits_10m_single ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS min_rows_for_wide_part = 0, min_bytes_for_wide_part = 0 CREATE TABLE hits_compact AS hits_10m_single ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS min_bytes_for_wide_part = '10M' CREATE TABLE hits_buffer AS hits_10m_single ENGINE = Buffer(default, hits_wide, 16, 10, 100, 10000, 1000000, 10000000, 100000000) 1 1 INSERT INTO hits_wide(UserID) SELECT rand() FROM numbers(100) INSERT INTO hits_compact(UserID) SELECT rand() FROM numbers(1000) INSERT INTO hits_buffer(UserID) SELECT rand() FROM numbers(1000) DROP TABLE IF EXISTS hits_wide DROP TABLE IF EXISTS hits_compact DROP TABLE IF EXISTS hits_buffer