大佬们麻烦帮忙看下这个 CK 查询速度为啥比 MySQL 慢

查看 18|回复 0
作者:lbllol365   
单表两千万数据,MySQL 4C8G,24ms ,clickhouse 2C4G,282ms
MySQL:
SELECT
corp_id,
corp_user_id,
SUM(totalxx_num) totalxx_num,
SUM(total_xxx_num) total_xxx_num
from xxx.xxxx
where corp_id = 'sdd' and dept_id = 100 and send_day >= '2023-03-01 00:00:00'and send_day
CK:
SELECT
corp_id,
corp_user_id,
SUM(totalxx_num) totalxx_num,
SUM(total_xxx_num) total_xxx_num
from xxx.xxxx
where corp_id = 'sdd' and dept_id = 100 and send_day >= toDate('2023-03-01 00:00:00') and send_day
DDL:
create table xxxx
(
    id                          Int64,
    corp_id                     String,
    user_id                     Int64,
    corp_user_id                String,
    totalxx_num                      Int32,
    total_xxx_num               Int32,
    send_day                    Date
)
    engine = MergeTree PARTITION BY toMonday(send_day)
        PRIMARY KEY id
        ORDER BY (id, corp_id, user_id, send_day)
        SETTINGS index_granularity = 8192;
您需要登录后才可以回帖 登录 | 立即注册

返回顶部