2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: no-parallel
|
|
|
|
|
2022-06-23 10:58:34 +00:00
|
|
|
set allow_deprecated_syntax_for_merge_tree=1;
|
2020-11-17 16:56:36 +00:00
|
|
|
set optimize_on_insert = 0;
|
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 2, -1, 1) from system.numbers limit 10;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, version, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 4 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 4 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 0, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 1, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 2, 1, -1) from system.numbers limit 10;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 5 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 5 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 1000000;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 1000000;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-01-31 17:11:47 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
2020-04-22 13:52:07 +00:00
|
|
|
create table mult_tab (date Date, value UInt64, key UInt64, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date), 8192, sign, version);
|
|
|
|
insert into mult_tab select '2018-01-31', number, number, 0, if(number < 64, 1, -1) from system.numbers limit 128;
|
|
|
|
insert into mult_tab select '2018-01-31', number, number + 128, 0, if(number < 64, -1, 1) from system.numbers limit 128;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select date, value, version, sign from mult_tab final order by date, key, sign settings max_block_size=33;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-01-31 17:11:47 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2020-04-22 13:52:07 +00:00
|
|
|
select date, value, version, sign from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'Vertival merge';
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 2, -1, 1) from system.numbers limit 10;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, version, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 4 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 4 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 0, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 1, 1, -1) from system.numbers limit 10;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 2, 1, -1) from system.numbers limit 10;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 5 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 5 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
|
|
|
create table mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 1000000;
|
|
|
|
insert into mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 1000000;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select * from mult_tab final order by date, value, sign;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2019-04-16 14:13:13 +00:00
|
|
|
select * from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2018-03-01 04:51:54 +00:00
|
|
|
select '-------------------------';
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
drop table if exists mult_tab;
|
2020-04-22 13:52:07 +00:00
|
|
|
create table mult_tab (date Date, value UInt64, key UInt64, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0;
|
|
|
|
insert into mult_tab select '2018-01-31', number, number, 0, if(number < 64, 1, -1) from system.numbers limit 128;
|
|
|
|
insert into mult_tab select '2018-01-31', number, number + 128, 0, if(number < 64, -1, 1) from system.numbers limit 128;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks final';
|
2020-04-22 13:52:07 +00:00
|
|
|
select date, value, version, sign from mult_tab final order by date, key, sign settings max_block_size=33;
|
2019-04-16 14:13:13 +00:00
|
|
|
optimize table mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
select 'table with 2 blocks optimized';
|
2020-04-22 13:52:07 +00:00
|
|
|
select date, value, version, sign from mult_tab;
|
2018-02-02 13:20:28 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE mult_tab;
|