ClickHouse/tests/queries/0_stateless/02494_query_cache_totals_extremes.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.7 KiB
MySQL
Raw Normal View History

-- Tags: no-parallel
-- Tag no-parallel: Messes with internal cache
SYSTEM DROP QUERY CACHE;
DROP TABLE IF EXISTS tbl;
CREATE TABLE tbl (key UInt64, agg UInt64) ENGINE = MergeTree ORDER BY key;
INSERT INTO tbl VALUES (1, 3), (2, 2), (1, 4), (1, 1);
2023-05-05 16:04:12 +00:00
-- A query with totals calculation. The result should be written into / read from the query cache.
-- Check that both queries produce the same result and that a query cache entry exists.
SELECT '1st run:';
SELECT key, sum(agg) FROM tbl GROUP BY key WITH totals ORDER BY key SETTINGS use_query_cache = 1;
SELECT '2nd run:';
SELECT key, sum(agg) FROM tbl GROUP BY key WITH totals ORDER BY key SETTINGS use_query_cache = 1;
SELECT count(*) FROM system.query_cache;
SELECT '---';
SYSTEM DROP QUERY CACHE;
2023-05-05 16:04:12 +00:00
-- A query with extremes calculation. The result should be written into / read from the query cache.
-- Check that both queries produce the same result.
SELECT '1st run:';
SELECT key, sum(agg) FROM tbl GROUP BY key ORDER BY key SETTINGS use_query_cache = 1, extremes = 1;
SELECT '2nd run:';
SELECT key, sum(agg) FROM tbl GROUP BY key ORDER BY key SETTINGS use_query_cache = 1, extremes = 1;
SELECT count(*) FROM system.query_cache;
SELECT '---';
SYSTEM DROP QUERY CACHE;
2023-05-05 16:04:12 +00:00
-- A query with totals and extremes calculation. The result should be written into / read from the query cache.
-- Check that both queries produce the same result.
SELECT '1st run:';
SELECT key, sum(agg) FROM tbl GROUP BY key WITH totals ORDER BY key SETTINGS use_query_cache = 1, extremes = 1;
SELECT '2nd run:';
SELECT key, sum(agg) FROM tbl GROUP BY key WITH totals ORDER BY key SETTINGS use_query_cache = 1, extremes = 1;
SELECT count(*) FROM system.query_cache;
DROP TABLE IF EXISTS tbl;
SYSTEM DROP QUERY CACHE;