Merge pull request #40104 from ClickHouse/counting-resources-in-subqueries

A test for counting resources in subqueries
This commit is contained in:
Alexey Milovidov 2022-08-13 08:08:35 +03:00 committed by GitHub
commit 8d1d2ecbfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
-- the work for scalar subquery is properly accounted:
SET max_rows_to_read = 1000000;
SELECT 1 = (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError 158 }
-- the work for subquery in IN is properly accounted:
SET max_rows_to_read = 1000000;
SELECT 1 IN (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError 158 }
-- this query reads from the table twice:
SET max_rows_to_read = 15000000;
SELECT count() IN (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)) FROM test.hits WHERE NOT ignore(AdvEngineID); -- { serverError 158 }
-- the resources are properly accounted even if the subquery is evaluated in advance to facilitate the index analysis.
-- this query is using index and filter out the second reading pass.
SET max_rows_to_read = 1000000;
SELECT count() FROM test.hits WHERE CounterID > (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError 158 }
-- this query is using index but have to read all the data twice.
SET max_rows_to_read = 10000000;
SELECT count() FROM test.hits WHERE CounterID < (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError 158 }