ClickHouse/tests/queries/0_stateless/03008_optimize_equal_ranges.sql

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

30 lines
1.3 KiB
MySQL
Raw Normal View History

2024-03-12 16:43:55 +00:00
DROP TABLE IF EXISTS t_optimize_equal_ranges;
CREATE TABLE t_optimize_equal_ranges (a UInt64, b String, c UInt64) ENGINE = MergeTree ORDER BY a;
SET max_block_size = 1024;
SET max_bytes_before_external_group_by = 0;
SET optimize_aggregation_in_order = 0;
2024-03-15 00:40:28 +00:00
SET optimize_use_projections = 0;
2024-03-12 16:43:55 +00:00
INSERT INTO t_optimize_equal_ranges SELECT 0, toString(number), number FROM numbers(30000);
INSERT INTO t_optimize_equal_ranges SELECT 1, toString(number), number FROM numbers(30000);
INSERT INTO t_optimize_equal_ranges SELECT 2, toString(number), number FROM numbers(30000);
2024-03-14 14:05:19 +00:00
SELECT a, uniqExact(b) FROM t_optimize_equal_ranges GROUP BY a ORDER BY a SETTINGS max_threads = 16;
SELECT a, uniqExact(b) FROM t_optimize_equal_ranges GROUP BY a ORDER BY a SETTINGS max_threads = 1;
SELECT a, sum(c) FROM t_optimize_equal_ranges GROUP BY a ORDER BY a SETTINGS max_threads = 16;
SELECT a, sum(c) FROM t_optimize_equal_ranges GROUP BY a ORDER BY a SETTINGS max_threads = 1;
2024-03-12 16:43:55 +00:00
SYSTEM FLUSH LOGS;
SELECT
used_aggregate_functions[1] AS func,
2024-03-14 14:05:19 +00:00
Settings['max_threads'] AS threads,
2024-03-12 16:43:55 +00:00
ProfileEvents['AggregationOptimizedEqualRangesOfKeys'] > 0
FROM system.query_log
WHERE type = 'QueryFinish' AND current_database = currentDatabase() AND query LIKE '%SELECT%FROM%t_optimize_equal_ranges%'
2024-03-14 14:05:19 +00:00
ORDER BY func, threads;
2024-03-12 16:43:55 +00:00
DROP TABLE t_optimize_equal_ranges;