【发布时间】:2020-10-09 06:43:45
【问题描述】:
我们有一个时间序列表,定义如下
CREATE TABLE timeseries.mytable
(
`ts` DateTime('UTC'),
`src_ip` String,
`dst_ip` String,
`col_other` String
)
ENGINE = MergeTree()
PARTITION BY toDate(tr)
ORDER BY (dst_ip,ts,src_ip)
SETTINGS index_granularity = 8192
SELECT count(*) FROM timeseries.mytable;
# Elapsed 0.004 sec. Has 383M records
SELECT count(*) FROM timeseries.timeseries WHERE dst_ip = 'a.b.c.d';
# Elapsed: 0.085 sec.
SELECT count(*) FROM timeseries.timeseries WHERE src_ip = 'a.b.c.d';
# Elapsed: 53.031 sec
从上面可以看出,使用第一个排好序的列 (dst_ip) 过滤数据非常快。
如何更快地使用第三个排序列 (src_ip) 进行选择?
【问题讨论】:
标签: clickhouse