【发布时间】:2019-12-16 15:47:21
【问题描述】:
我开始学习 CH 并且在尝试提高查询速度时似乎遇到了死胡同,表是这样创建的
CREATE TABLE default.stats(
aa String,
ab String,
user_id UInt16,
ac UInt32,
ad UInt8,
ae UInt8,
created_time DateTime,
created_date Date,
af UInt8,
ag UInt32,
ah UInt32,
ai String,
aj String)
ENGINE = MergeTree
PARTITION BY toYYYYMM(created_time)
ORDER BY(created_time, user_id)
我正在运行这样的查询
SELECT ad, created_time, ab, aa, user_id, ac, ag, af
FROM stats
WHERE user_id = 1 AND lowerUTF8(ab) = 'xxxxxxxxx' AND ad != 12
ORDER BY created_time DESC
LIMIT 50 OFFSET 0
这是 50 行集合中的结果。经过:2.881 秒。处理了 7462 万行
如果我在没有订单部分的情况下运行相同的查询,集合中有 50 行。经过:0.020 秒。处理了 49150 行
如果理论上查询只需要订购大约 10k(所有返回的行没有限制)行,为什么它似乎处理了表中的所有行?我错过了什么和/或如何提高 CH 的速度?
【问题讨论】:
标签: clickhouse