Add test for #26965

* Add a test for 'WITH'+CTE performance if enable_global_with_statement is enabled
This commit is contained in:
Pablo Alegre 2022-03-09 17:27:38 +01:00 committed by Pablo Alegre
parent 892bcd183b
commit 6fe26d24e7
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,4 @@
1000
1000
1000
3

View File

@ -0,0 +1,27 @@
DROP TABLE IF EXISTS ev;
DROP TABLE IF EXISTS idx;
CREATE TABLE ev (a Int32, b Int32) Engine=MergeTree() ORDER BY a;
CREATE TABLE idx (a Int32) Engine=MergeTree() ORDER BY a;
INSERT INTO ev SELECT number, number FROM numbers(100000000);
INSERT INTO idx SELECT number*5 FROM numbers(1000);
SET enable_global_with_statement = 1;
-- test_enable_global_with_statement_performance_1
WITH 'test' AS u SELECT count()FROM ev WHERE a IN (SELECT a FROM idx);
-- test_enable_global_with_statement_performance_2
SELECT count() FROM ev WHERE a IN (SELECT a FROM idx);
SET enable_global_with_statement = 0;
-- test_enable_global_with_statement_performance_3
WITH 'test' AS u SELECT count() FROM ev WHERE a IN (SELECT a FROM idx);
SYSTEM FLUSH LOGS;
SELECT count(read_rows) FROM (SELECT read_rows FROM system.query_log WHERE current_database=currentDatabase() AND type='QueryFinish' AND query LIKE '%test_enable_global_with_statement_performance%' ORDER BY event_date, event_time DESC LIMIT 3) GROUP BY read_rows;
DROP TABLE IF EXISTS ev;
DROP TABLE IF EXISTS idx;