This commit is contained in:
Anton Popov 2024-05-30 16:23:23 +00:00
parent 6ab029b465
commit 450bcd7f70
5 changed files with 80 additions and 36 deletions

View File

@ -1,34 +0,0 @@
DROP TABLE IF EXISTS t_ind_merge;
CREATE TABLE t_ind_merge (a UInt64, b UInt64, c UInt64, d UInt64, INDEX idx_b b TYPE minmax)
ENGINE = MergeTree
ORDER BY a SETTINGS
index_granularity = 64,
vertical_merge_algorithm_min_rows_to_activate = 1,
vertical_merge_algorithm_min_columns_to_activate = 1,
min_bytes_for_wide_part = 0;
INSERT INTO t_ind_merge SELECT number, number, rand(), rand() from numbers(1000);
INSERT INTO t_ind_merge SELECT number, number, rand(), rand() from numbers(1000);
SELECT count() FROM t_ind_merge WHERE b < 100 SETTINGS force_data_skipping_indices = 'idx_b';
EXPLAIN indexes = 1 SELECT count() FROM t_ind_merge WHERE b < 100;
OPTIMIZE TABLE t_ind_merge FINAL;
SELECT count() FROM t_ind_merge WHERE b < 100 SETTINGS force_data_skipping_indices = 'idx_b';
EXPLAIN indexes = 1 SELECT count() FROM t_ind_merge WHERE b < 100;
DROP TABLE t_ind_merge;
SYSTEM FLUSH LOGS;
WITH
(SELECT uuid FROM system.tables WHERE database = currentDatabase() AND table = 't_ind_merge') AS uuid,
extractAllGroupsVertical(message, 'containing (\\d+) columns \((\\d+) merged, (\\d+) gathered\)')[1] AS groups
SELECT
groups[1] AS total,
groups[2] AS merged,
groups[3] AS gathered
FROM system.text_log
WHERE query_id = uuid || '::all_1_2_1' AND notEmpty(groups)
ORDER BY event_time_microseconds;

View File

@ -3,7 +3,7 @@ Expression ((Project names + Projection))
Aggregating
Expression (Before GROUP BY)
Filter ((WHERE + Change column names to column identifiers))
ReadFromMergeTree (default.t_ind_merge)
ReadFromMergeTree (default.t_ind_merge_1)
Indexes:
PrimaryKey
Condition: true
@ -19,7 +19,7 @@ Expression ((Project names + Projection))
Aggregating
Expression (Before GROUP BY)
Filter ((WHERE + Change column names to column identifiers))
ReadFromMergeTree (default.t_ind_merge)
ReadFromMergeTree (default.t_ind_merge_1)
Indexes:
PrimaryKey
Condition: true
@ -30,3 +30,4 @@ Expression ((Project names + Projection))
Description: minmax GRANULARITY 1
Parts: 1/1
Granules: 4/32
4 1 3

View File

@ -0,0 +1,35 @@
DROP TABLE IF EXISTS t_ind_merge_1;
CREATE TABLE t_ind_merge_1 (a UInt64, b UInt64, c UInt64, d UInt64, INDEX idx_b b TYPE minmax)
ENGINE = MergeTree
ORDER BY a SETTINGS
index_granularity = 64,
vertical_merge_algorithm_min_rows_to_activate = 1,
vertical_merge_algorithm_min_columns_to_activate = 1,
min_bytes_for_wide_part = 0;
INSERT INTO t_ind_merge_1 SELECT number, number, rand(), rand() FROM numbers(1000);
INSERT INTO t_ind_merge_1 SELECT number, number, rand(), rand() FROM numbers(1000);
SELECT count() FROM t_ind_merge_1 WHERE b < 100 SETTINGS force_data_skipping_indices = 'idx_b';
EXPLAIN indexes = 1 SELECT count() FROM t_ind_merge_1 WHERE b < 100;
OPTIMIZE TABLE t_ind_merge_1 FINAL;
SELECT count() FROM t_ind_merge_1 WHERE b < 100 SETTINGS force_data_skipping_indices = 'idx_b';
EXPLAIN indexes = 1 SELECT count() FROM t_ind_merge_1 WHERE b < 100;
SYSTEM FLUSH LOGS;
WITH
(SELECT uuid FROM system.tables WHERE database = currentDatabase() AND table = 't_ind_merge_1') AS uuid,
extractAllGroupsVertical(message, 'containing (\\d+) columns \((\\d+) merged, (\\d+) gathered\)')[1] AS groups
SELECT
groups[1] AS total,
groups[2] AS merged,
groups[3] AS gathered
FROM system.text_log
WHERE query_id = uuid || '::all_1_2_1' AND notEmpty(groups)
ORDER BY event_time_microseconds;
DROP TABLE t_ind_merge_1;

View File

@ -0,0 +1,41 @@
DROP TABLE IF EXISTS t_ind_merge_2;
CREATE TABLE t_ind_merge_2 (
a UInt64,
b UInt64,
c UInt64,
d UInt64,
e UInt64,
f UInt64,
INDEX idx_a a TYPE minmax,
INDEX idx_b b TYPE minmax,
INDEX idx_cd c * d TYPE minmax,
INDEX idx_d1 d TYPE minmax,
INDEX idx_d2 d TYPE set(3),
INDEX idx_e e TYPE set(3))
ENGINE = MergeTree
ORDER BY a SETTINGS
index_granularity = 64,
vertical_merge_algorithm_min_rows_to_activate = 1,
vertical_merge_algorithm_min_columns_to_activate = 1,
min_bytes_for_wide_part = 0;
INSERT INTO t_ind_merge_2 SELECT number, number, rand(), rand(), rand(), rand() FROM numbers(1000);
INSERT INTO t_ind_merge_2 SELECT number, number, rand(), rand(), rand(), rand() FROM numbers(1000);
OPTIMIZE TABLE t_ind_merge_2 FINAL;
SYSTEM FLUSH LOGS;
--- merged: a, c, d; gathered: b, e, f
WITH
(SELECT uuid FROM system.tables WHERE database = currentDatabase() AND table = 't_ind_merge_2') AS uuid,
extractAllGroupsVertical(message, 'containing (\\d+) columns \((\\d+) merged, (\\d+) gathered\)')[1] AS groups
SELECT
groups[1] AS total,
groups[2] AS merged,
groups[3] AS gathered
FROM system.text_log
WHERE query_id = uuid || '::all_1_2_1' AND notEmpty(groups)
ORDER BY event_time_microseconds;
DROP TABLE t_ind_merge_2;