2024-02-27 17:41:40 +00:00
|
|
|
SET optimize_use_implicit_projections = 0;
|
|
|
|
|
2022-08-11 05:44:42 +00:00
|
|
|
-- the work for scalar subquery is properly accounted:
|
|
|
|
SET max_rows_to_read = 1000000;
|
2024-05-31 08:44:16 +00:00
|
|
|
SELECT 1 = (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError TOO_MANY_ROWS }
|
2022-08-11 05:44:42 +00:00
|
|
|
|
|
|
|
-- the work for subquery in IN is properly accounted:
|
|
|
|
SET max_rows_to_read = 1000000;
|
2024-05-31 08:44:16 +00:00
|
|
|
SELECT 1 IN (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError TOO_MANY_ROWS }
|
2022-08-11 05:44:42 +00:00
|
|
|
|
|
|
|
-- this query reads from the table twice:
|
|
|
|
SET max_rows_to_read = 15000000;
|
2024-05-31 08:44:16 +00:00
|
|
|
SELECT count() IN (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)) FROM test.hits WHERE NOT ignore(AdvEngineID); -- { serverError TOO_MANY_ROWS }
|
2022-08-11 05:44:42 +00:00
|
|
|
|
|
|
|
-- 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;
|
2024-05-31 08:44:16 +00:00
|
|
|
SELECT count() FROM test.hits WHERE CounterID > (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError TOO_MANY_ROWS }
|
2022-08-11 05:44:42 +00:00
|
|
|
|
|
|
|
-- this query is using index but have to read all the data twice.
|
2022-08-13 00:20:31 +00:00
|
|
|
SET max_rows_to_read = 10000000;
|
2024-05-31 08:44:16 +00:00
|
|
|
SELECT count() FROM test.hits WHERE CounterID < (SELECT count() FROM test.hits WHERE NOT ignore(AdvEngineID)); -- { serverError TOO_MANY_ROWS }
|