mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
tests for partition pruning
This commit is contained in:
parent
2ce63aa9f9
commit
4445cb6495
118
tests/queries/0_stateless/01508_partition_pruning.queries
Normal file
118
tests/queries/0_stateless/01508_partition_pruning.queries
Normal file
@ -0,0 +1,118 @@
|
||||
DROP TABLE IF EXISTS tMM
|
||||
DROP TABLE IF EXISTS tDD
|
||||
DROP TABLE IF EXISTS sDD
|
||||
DROP TABLE IF EXISTS xMM
|
||||
CREATE TABLE tMM(d DateTime,a Int64) ENGINE = MergeTree PARTITION BY toYYYYMM(d) ORDER BY tuple()
|
||||
SYSTEM STOP MERGES tMM;
|
||||
INSERT INTO tMM SELECT toDateTime('2020-08-16 00:00:00') + number*60, number FROM numbers(5000)
|
||||
INSERT INTO tMM SELECT toDateTime('2020-08-16 00:00:00') + number*60, number FROM numbers(5000)
|
||||
INSERT INTO tMM SELECT toDateTime('2020-09-01 00:00:00') + number*60, number FROM numbers(5000)
|
||||
INSERT INTO tMM SELECT toDateTime('2020-09-01 00:00:00') + number*60, number FROM numbers(5000)
|
||||
INSERT INTO tMM SELECT toDateTime('2020-10-01 00:00:00') + number*60, number FROM numbers(5000)
|
||||
INSERT INTO tMM SELECT toDateTime('2020-10-15 00:00:00') + number*60, number FROM numbers(5000)
|
||||
|
||||
CREATE TABLE tDD(d DateTime,a Int) ENGINE = MergeTree PARTITION BY toYYYYMMDD(d) ORDER BY tuple()
|
||||
insert into tDD select toDateTime(toDate('2020-09-23')), number from numbers(10000) UNION ALL select toDateTime(toDateTime('2020-09-23 11:00:00')), number from numbers(10000) UNION ALL select toDateTime(toDate('2020-09-24')), number from numbers(10000) UNION ALL select toDateTime(toDate('2020-09-25')), number from numbers(10000) UNION ALL select toDateTime(toDate('2020-08-15')), number from numbers(10000);
|
||||
|
||||
CREATE TABLE sDD(d UInt64,a Int) ENGINE = MergeTree PARTITION BY toYYYYMM(toDate(intDiv(d,1000))) ORDER BY tuple()
|
||||
insert into sDD select (1597536000+number*60)*1000, number from numbers(5000);
|
||||
insert into sDD select (1597536000+number*60)*1000, number from numbers(5000);
|
||||
insert into sDD select (1598918400+number*60)*1000, number from numbers(5000);
|
||||
insert into sDD select (1598918400+number*60)*1000, number from numbers(5000);
|
||||
insert into sDD select (1601510400+number*60)*1000, number from numbers(5000);
|
||||
insert into sDD select (1602720000+number*60)*1000, number from numbers(5000);
|
||||
|
||||
CREATE TABLE xMM(d DateTime,a Int64, f Int64) ENGINE = MergeTree PARTITION BY (toYYYYMM(d), a) ORDER BY tuple()
|
||||
SYSTEM STOP MERGES xMM;
|
||||
INSERT INTO xMM SELECT toDateTime('2020-08-16 00:00:00') + number*60, 1, number FROM numbers(5000)
|
||||
INSERT INTO xMM SELECT toDateTime('2020-08-16 00:00:00') + number*60, 2, number FROM numbers(5000)
|
||||
INSERT INTO xMM SELECT toDateTime('2020-09-01 00:00:00') + number*60, 3, number FROM numbers(5000)
|
||||
INSERT INTO xMM SELECT toDateTime('2020-09-01 00:00:00') + number*60, 2, number FROM numbers(5000)
|
||||
INSERT INTO xMM SELECT toDateTime('2020-10-01 00:00:00') + number*60, 1, number FROM numbers(5000)
|
||||
INSERT INTO xMM SELECT toDateTime('2020-10-15 00:00:00') + number*60, 1, number FROM numbers(5000)
|
||||
|
||||
|
||||
|
||||
select uniqExact(_part), count() from tMM where toDate(d)=toDate('2020-09-15')
|
||||
select uniqExact(_part), count() from tMM where toDate(d)=toDate('2020-09-01')
|
||||
select uniqExact(_part), count() from tMM where toDate(d)=toDate('2020-10-15')
|
||||
select uniqExact(_part), count() from tMM where toDate(d)='2020-09-15'
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)=202009
|
||||
select uniqExact(_part), count() from tMM where toYYYYMMDD(d)=20200816
|
||||
select uniqExact(_part), count() from tMM where toYYYYMMDD(d)=20201015
|
||||
select uniqExact(_part), count() from tMM where toDate(d)='2020-10-15'
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-09-01 00:00:00' and d<'2020-10-15 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-01-16 00:00:00' and d < toDateTime('2021-08-17 00:00:00')
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-09-16 00:00:00' and d < toDateTime('2020-10-01 00:00:00')
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-09-12 00:00:00' and d < '2020-10-16 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) >= '2020-09-12 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) = '2020-09-01 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) = '2020-10-01 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) >= '2020-09-15 00:00:00' and d < '2020-10-16 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202010
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202009
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202010 and toStartOfDay(d) = '2020-10-01 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) >= 202009 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) > 202009 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202009 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202010 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202010
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d-1)+1 = 202010
|
||||
select uniqExact(_part), count() from tMM where toStartOfMonth(d) >= '2020-09-15'
|
||||
select uniqExact(_part), count() from tMM where toStartOfMonth(d) >= '2020-09-01'
|
||||
select uniqExact(_part), count() from tMM where toStartOfMonth(d) >= '2020-09-01' and toStartOfMonth(d) < '2020-10-01'
|
||||
|
||||
SYSTEM START MERGES tMM
|
||||
OPTIMIZE TABLE tMM FINAL
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d-1)+1 = 202010
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202010
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202010
|
||||
|
||||
OPTIMIZE TABLE tDD FINAL
|
||||
|
||||
select uniqExact(_part), count() from tDD where toDate(d)=toDate('2020-09-24')
|
||||
select uniqExact(_part), count() FROM tDD WHERE toDate(d) = toDate('2020-09-24')
|
||||
select uniqExact(_part), count() FROM tDD WHERE toDate(d) = '2020-09-24'
|
||||
select uniqExact(_part), count() FROM tDD WHERE toDate(d) >= '2020-09-23' and toDate(d) <= '2020-09-26'
|
||||
select uniqExact(_part), count() FROM tDD WHERE toYYYYMMDD(d) >= 20200923 and toDate(d) <= '2020-09-26'
|
||||
|
||||
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000))-1)+1 = 202010
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000))-1) = 202010
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000))-1) = 202110
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000)))+1 > 202009 and toStartOfDay(toDateTime(intDiv(d,1000))) < '2020-10-02 00:00:00'
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000)))+1 > 202009 and toDateTime(intDiv(d,1000)) < '2020-10-01 00:00:00'
|
||||
select uniqExact(_part), count() from sDD where d >= 1598918400000
|
||||
select uniqExact(_part), count() from sDD where d >= 1598918400000 and toYYYYMM(toDateTime(intDiv(d,1000))-1) < 202010
|
||||
|
||||
|
||||
|
||||
select uniqExact(_part), count() from xMM where toStartOfDay(d) >= '2020-10-01 00:00:00'
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00'
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-10-01 00:00:00'
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00' and a=1
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00' and a<>3
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-10-01 00:00:00' and a<>3
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-11-01 00:00:00' and a = 1
|
||||
select uniqExact(_part), count() from xMM where a = 1
|
||||
select uniqExact(_part), count() from xMM where a = 66
|
||||
select uniqExact(_part), count() from xMM where a <> 66
|
||||
select uniqExact(_part), count() from xMM where a = 2
|
||||
|
||||
SYSTEM START MERGES xMM;
|
||||
optimize table xMM final;
|
||||
|
||||
select uniqExact(_part), count() from xMM where a = 1
|
||||
select uniqExact(_part), count() from xMM where toStartOfDay(d) >= '2020-10-01 00:00:00'
|
||||
select uniqExact(_part), count() from xMM where a <> 66
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00' and a<>3
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-10-01 00:00:00' and a<>3
|
||||
|
||||
DROP TABLE tMM
|
||||
DROP TABLE tDD
|
||||
DROP TABLE sDD
|
||||
DROP TABLE xMM
|
||||
|
||||
|
||||
|
177
tests/queries/0_stateless/01508_partition_pruning.reference
Normal file
177
tests/queries/0_stateless/01508_partition_pruning.reference
Normal file
@ -0,0 +1,177 @@
|
||||
select uniqExact(_part), count() from tMM where toDate(d)=toDate('2020-09-15')
|
||||
Selected 0 parts by partition key, 0 parts by primary key, 0 marks by primary key, 0 marks to read from 0 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toDate(d)=toDate('2020-09-01')
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toDate(d)=toDate('2020-10-15')
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toDate(d)='2020-09-15'
|
||||
Selected 0 parts by partition key, 0 parts by primary key, 0 marks by primary key, 0 marks to read from 0 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)=202009
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMMDD(d)=20200816
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMMDD(d)=20201015
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toDate(d)='2020-10-15'
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-09-01 00:00:00' and d<'2020-10-15 00:00:00'
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-01-16 00:00:00' and d < toDateTime('2021-08-17 00:00:00')
|
||||
Selected 6 parts by partition key, 6 parts by primary key, 6 marks by primary key, 6 marks to read from 6 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-09-16 00:00:00' and d < toDateTime('2020-10-01 00:00:00')
|
||||
Selected 0 parts by partition key, 0 parts by primary key, 0 marks by primary key, 0 marks to read from 0 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where d >= '2020-09-12 00:00:00' and d < '2020-10-16 00:00:00'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) >= '2020-09-12 00:00:00'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) = '2020-09-01 00:00:00'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) = '2020-10-01 00:00:00'
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toStartOfDay(d) >= '2020-09-15 00:00:00' and d < '2020-10-16 00:00:00'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202010
|
||||
Selected 4 parts by partition key, 4 parts by primary key, 4 marks by primary key, 4 marks to read from 4 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202009
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202010 and toStartOfDay(d) = '2020-10-01 00:00:00'
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) >= 202009 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) > 202009 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202009 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202010 and toStartOfDay(d) < '2020-10-02 00:00:00'
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202010
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d-1)+1 = 202010
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toStartOfMonth(d) >= '2020-09-15'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toStartOfMonth(d) >= '2020-09-01'
|
||||
Selected 4 parts by partition key, 4 parts by primary key, 4 marks by primary key, 4 marks to read from 4 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toStartOfMonth(d) >= '2020-09-01' and toStartOfMonth(d) < '2020-10-01'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d-1)+1 = 202010
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d)+1 > 202010
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from tMM where toYYYYMM(d) between 202009 and 202010
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from tDD where toDate(d)=toDate('2020-09-24')
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() FROM tDD WHERE toDate(d) = toDate('2020-09-24')
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() FROM tDD WHERE toDate(d) = '2020-09-24'
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() FROM tDD WHERE toDate(d) >= '2020-09-23' and toDate(d) <= '2020-09-26'
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 4 marks by primary key, 4 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() FROM tDD WHERE toYYYYMMDD(d) >= 20200923 and toDate(d) <= '2020-09-26'
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 4 marks by primary key, 4 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000))-1)+1 = 202010
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000))-1) = 202010
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000))-1) = 202110
|
||||
Selected 0 parts by partition key, 0 parts by primary key, 0 marks by primary key, 0 marks to read from 0 ranges
|
||||
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000)))+1 > 202009 and toStartOfDay(toDateTime(intDiv(d,1000))) < '2020-10-02 00:00:00'
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from sDD where toYYYYMM(toDateTime(intDiv(d,1000)))+1 > 202009 and toDateTime(intDiv(d,1000)) < '2020-10-01 00:00:00'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from sDD where d >= 1598918400000
|
||||
Selected 4 parts by partition key, 4 parts by primary key, 4 marks by primary key, 4 marks to read from 4 ranges
|
||||
|
||||
select uniqExact(_part), count() from sDD where d >= 1598918400000 and toYYYYMM(toDateTime(intDiv(d,1000))-1) < 202010
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where toStartOfDay(d) >= '2020-10-01 00:00:00'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00'
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-10-01 00:00:00'
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00' and a=1
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00' and a<>3
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-10-01 00:00:00' and a<>3
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-11-01 00:00:00' and a = 1
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where a = 1
|
||||
Selected 3 parts by partition key, 3 parts by primary key, 3 marks by primary key, 3 marks to read from 3 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where a = 66
|
||||
Selected 0 parts by partition key, 0 parts by primary key, 0 marks by primary key, 0 marks to read from 0 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where a <> 66
|
||||
Selected 6 parts by partition key, 6 parts by primary key, 6 marks by primary key, 6 marks to read from 6 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where a = 2
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where a = 1
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where toStartOfDay(d) >= '2020-10-01 00:00:00'
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where a <> 66
|
||||
Selected 5 parts by partition key, 5 parts by primary key, 5 marks by primary key, 5 marks to read from 5 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d <= '2020-10-01 00:00:00' and a<>3
|
||||
Selected 2 parts by partition key, 2 parts by primary key, 2 marks by primary key, 2 marks to read from 2 ranges
|
||||
|
||||
select uniqExact(_part), count() from xMM where d >= '2020-09-01 00:00:00' and d < '2020-10-01 00:00:00' and a<>3
|
||||
Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
|
||||
|
37
tests/queries/0_stateless/01508_partition_pruning.sh
Executable file
37
tests/queries/0_stateless/01508_partition_pruning.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#--------------------------------------------
|
||||
# Description of test result:
|
||||
# Test the correctness of the optimization
|
||||
# by asserting read marks in the log.
|
||||
# Relation of read marks and optimization:
|
||||
# read marks =
|
||||
# the number of monotonic marks filtered through predicates
|
||||
# + no monotonic marks count
|
||||
#--------------------------------------------
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
#export CLICKHOUSE_CLIENT="clickhouse-client --send_logs_level=none"
|
||||
#export CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL=none
|
||||
#export CURDIR=.
|
||||
|
||||
|
||||
queries="${CURDIR}/01508_partition_pruning.queries"
|
||||
while IFS= read -r sql
|
||||
do
|
||||
[ -z "$sql" ] && continue
|
||||
if [[ "$sql" == select* ]] ;
|
||||
then
|
||||
CLICKHOUSE_CLIENT=$(echo ${CLICKHOUSE_CLIENT} | sed 's/'"--send_logs_level=${CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL}"'/--send_logs_level=debug/g')
|
||||
echo "$sql"
|
||||
${CLICKHOUSE_CLIENT} --query "$sql" 2>&1 | grep -oh "Selected .* parts by partition key, *. parts by primary key, .* marks by primary key, .* marks to read from .* ranges.*$"
|
||||
CLICKHOUSE_CLIENT=$(echo ${CLICKHOUSE_CLIENT} | sed 's/--send_logs_level=debug/'"--send_logs_level=${CLICKHOUSE_CLIENT_SERVER_LOGS_LEVEL}"'/g')
|
||||
echo ""
|
||||
else
|
||||
${CLICKHOUSE_CLIENT} --query "$sql"
|
||||
fi
|
||||
done < "$queries"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user