CREATE TABLE distinct_cardinality_high (high UInt64, medium UInt64, low UInt64) ENGINE MergeTree() ORDER BY (high, medium)
INSERT INTO distinct_cardinality_high SELECT number % 1e6, number % 1e4, number % 1e2 FROM numbers_mt(1e8)
SELECT DISTINCT high FROM distinct_cardinality_high FORMAT Null
SELECT DISTINCT high, low FROM distinct_cardinality_high FORMAT Null
SELECT DISTINCT high, medium FROM distinct_cardinality_high FORMAT Null
SELECT DISTINCT high, medium, low FROM distinct_cardinality_high FORMAT Null
SELECT DISTINCT high, medium FROM distinct_cardinality_high ORDER BY medium FORMAT Null
SELECT DISTINCT high, medium FROM distinct_cardinality_high ORDER BY high FORMAT Null
SELECT DISTINCT high, low FROM distinct_cardinality_high ORDER BY low FORMAT Null
SELECT DISTINCT high, medium, low FROM distinct_cardinality_high ORDER BY low FORMAT Null
DROP TABLE IF EXISTS distinct_cardinality_high
CREATE TABLE distinct_cardinality_low (low UInt64, medium UInt64, high UInt64) ENGINE MergeTree() ORDER BY (low, medium)
INSERT INTO distinct_cardinality_low SELECT number % 1e2, number % 1e4, number % 1e6 FROM numbers_mt(1e8)
SELECT DISTINCT low FROM distinct_cardinality_low FORMAT Null
SELECT DISTINCT low, medium FROM distinct_cardinality_low FORMAT Null
SELECT DISTINCT low, high FROM distinct_cardinality_low FORMAT Null
SELECT DISTINCT low, medium, high FROM distinct_cardinality_low FORMAT Null
SELECT DISTINCT low, medium FROM distinct_cardinality_low ORDER BY medium FORMAT Null
SELECT DISTINCT low, medium FROM distinct_cardinality_low ORDER BY low FORMAT Null
SELECT DISTINCT low, high FROM distinct_cardinality_low ORDER BY high FORMAT Null
SELECT DISTINCT low, medium, high FROM distinct_cardinality_low ORDER BY high FORMAT Null
DROP TABLE IF EXISTS distinct_cardinality_low