2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS merge_tree_in_subqueries;
|
|
|
|
CREATE TABLE merge_tree_in_subqueries (id UInt64, name String, num UInt64) ENGINE = MergeTree ORDER BY (id, name);
|
|
|
|
INSERT INTO merge_tree_in_subqueries VALUES(1, 'test1', 42);
|
|
|
|
INSERT INTO merge_tree_in_subqueries VALUES(2, 'test2', 8);
|
|
|
|
INSERT INTO merge_tree_in_subqueries VALUES(3, 'test3', 8);
|
|
|
|
INSERT INTO merge_tree_in_subqueries VALUES(4, 'test4', 1985);
|
|
|
|
INSERT INTO merge_tree_in_subqueries VALUES(5, 'test5', 0);
|
2018-01-21 07:30:07 +00:00
|
|
|
|
|
|
|
-- Index scans.
|
|
|
|
SET force_primary_key = 1;
|
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT * FROM merge_tree_in_subqueries WHERE id IN (SELECT * FROM system.numbers LIMIT 0);
|
2018-01-21 07:30:07 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT * FROM merge_tree_in_subqueries WHERE id IN (SELECT * FROM system.numbers LIMIT 2, 3) ORDER BY id;
|
|
|
|
SELECT * FROM merge_tree_in_subqueries WHERE name IN (SELECT 'test' || toString(number) FROM system.numbers LIMIT 2, 3) ORDER BY id;
|
2018-01-21 07:30:07 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT id AS id2, name AS value FROM merge_tree_in_subqueries WHERE (value, id2) IN (SELECT 'test' || toString(number), number FROM system.numbers LIMIT 2, 3) ORDER BY id;
|
2018-01-21 07:30:07 +00:00
|
|
|
|
|
|
|
-- Non-index scans.
|
|
|
|
SET force_primary_key = 0;
|
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT id AS id2, name AS value FROM merge_tree_in_subqueries WHERE num IN (SELECT number FROM system.numbers LIMIT 10) ORDER BY id;
|
|
|
|
SELECT id AS id2, name AS value FROM merge_tree_in_subqueries WHERE (id, num) IN (SELECT number, number + 6 FROM system.numbers LIMIT 10) ORDER BY id;
|
2018-01-21 07:30:07 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS merge_tree_in_subqueries;
|