Skip to content

Instantly share code, notes, and snippets.

@SaltTan
SaltTan / ANY INNER
Last active January 23, 2020 20:40
drop table if exists t1;
drop table if exists t2;
CREATE TABLE t1 (n Int8, s1 String) ENGINE = Log;
CREATE TABLE t2 (n Int8, s2 String) ENGINE = Log;
insert into t1 values (1, 'One'), (2, 'Two'), (3, 'Three'), (1, 'One`'), (4, 'Four');
insert into t2 values (1, 'Un'), (2, 'Deux'), (3, 'Trois'), (1, 'Un`'), (5, 'Cinq');
20.1.2.4
CREATE TABLE amt
(
`ip` Int32,
`first` SimpleAggregateFunction(min, DateTime),
`last` SimpleAggregateFunction(max, DateTime)
)
ENGINE = AggregatingMergeTree()
ORDER BY ip;
ALTER TABLE amt MODIFY TTL last + toIntervalMinute(10);
SELECT f_string
FROM distributed_table
WHERE partition_key = '2019-08-23' AND pk_f1 = 118129 AND pk_f2= -2
GROUP BY f_string
2019.08.26 19:35:32.294127 [ 150 ] {905a17ff-ac63-4ea8-aca9-1f8410c67bcb} <Debug> executeQuery: Query pipeline:
Expression
MergeSorting
PartialSorting
Expression
SELECT f_string
FROM distributed_table
WHERE partition_key = '2019-08-23' AND pk_f1 = 118129 AND pk_f2= -2
GROUP BY f_string LIMIT 10
2019.08.27 17:56:26.823105 [ 56 ] {e283771b-f472-4b75-a999-95cc7b7bc216} <Debug> executeQuery: Query pipeline:
Limit
Expression
Expression
MergingAggregatedMemoryEfficient