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(merge, hits, 16, 10, 100, 10000, 1000000, 10000000, 100000000)
INSERT INTO hits_wide(UserID) VALUES (rand())
INSERT INTO hits_wide(UserID) SELECT rand() FROM numbers(100)
INSERT INTO hits_wide(UserID) SELECT rand() FROM numbers(1000)
INSERT INTO hits_wide(UserID) SELECT rand() FROM numbers(10000)
INSERT INTO hits_compact(UserID) VALUES (rand())
INSERT INTO hits_compact(UserID) SELECT rand() FROM numbers(100)
INSERT INTO hits_compact(UserID) SELECT rand() FROM numbers(1000)
INSERT INTO hits_compact(UserID) SELECT rand() FROM numbers(10000)
INSERT INTO hits_buffer(UserID) VALUES (rand())
INSERT INTO hits_buffer(UserID) SELECT rand() FROM numbers(100)
INSERT INTO hits_buffer(UserID) SELECT rand() FROM numbers(1000)
INSERT INTO hits_buffer(UserID) SELECT rand() FROM numbers(10000)
DROP TABLE IF EXISTS hits_wide
DROP TABLE IF EXISTS hits_compact
DROP TABLE IF EXISTS hits_buffer