Add cardinalities test

This commit is contained in:
Igor Markelov 2024-05-28 11:22:12 +00:00
parent c3ac011795
commit 1630651f54
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,38 @@
Alex 1 63 0
Alex 1 65 0
Alex 1 239 0
Alex 2 224 0
Alex 4 83 0
Alex 4 134 0
Alex 4 192 0
Bob 2 53 0
Bob 4 100 0
Bob 4 177 0
Bob 4 177 0
Nikita 1 173 0
Nikita 1 228 0
Nikita 2 148 0
Nikita 2 148 0
Nikita 2 208 0
Alex 1 63 1
Alex 1 65 1
Alex 1 239 1
Alex 2 128 1
Alex 2 128 1
Alex 2 224 1
Alex 4 83 1
Alex 4 83 1
Alex 4 134 1
Alex 4 134 1
Alex 4 192 1
Bob 2 53 1
Bob 2 53 1
Bob 2 187 1
Bob 2 187 1
Bob 4 100 1
Nikita 1 173 1
Nikita 1 228 1
Nikita 2 54 1
Nikita 2 54 1
Nikita 2 148 1
Nikita 2 208 1

View File

@ -0,0 +1,11 @@
-- Checks that RowOptimizer correctly selects the order for columns according to cardinality, with an empty ORDER BY.
-- There are 4 columns with cardinalities {name : 3, timestamp": 3, money: 17, flag: 2}, so the columns order must be {flag, name, timestamp, money}.
DROP TABLE IF EXISTS tab;
CREATE TABLE tab (name String, timestamp Int64, money UInt8, flag String) ENGINE = MergeTree ORDER BY () SETTINGS allow_experimental_optimized_row_order = True;
INSERT INTO tab VALUES ('Bob', 4, 100, '1'), ('Nikita', 2, 54, '1'), ('Nikita', 1, 228, '1'), ('Alex', 4, 83, '1'), ('Alex', 4, 134, '1'), ('Alex', 1, 65, '0'), ('Alex', 4, 134, '1'), ('Bob', 2, 53, '0'), ('Alex', 4, 83, '0'), ('Alex', 1, 63, '1'), ('Bob', 2, 53, '1'), ('Alex', 4, 192, '1'), ('Alex', 2, 128, '1'), ('Nikita', 2, 148, '0'), ('Bob', 4, 177, '0'), ('Nikita', 1, 173, '0'), ('Alex', 1, 239, '0'), ('Alex', 1, 63, '0'), ('Alex', 2, 224, '1'), ('Bob', 4, 177, '0'), ('Alex', 2, 128, '1'), ('Alex', 4, 134, '0'), ('Alex', 4, 83, '1'), ('Bob', 4, 100, '0'), ('Nikita', 2, 54, '1'), ('Alex', 1, 239, '1'), ('Bob', 2, 187, '1'), ('Alex', 1, 65, '1'), ('Bob', 2, 53, '1'), ('Alex', 2, 224, '0'), ('Alex', 4, 192, '0'), ('Nikita', 1, 173, '1'), ('Nikita', 2, 148, '1'), ('Bob', 2, 187, '1'), ('Nikita', 2, 208, '1'), ('Nikita', 2, 208, '0'), ('Nikita', 1, 228, '0'), ('Nikita', 2, 148, '0');
SELECT * FROM tab SETTINGS max_threads=1;
DROP TABLE tab;