clickhouse 03. 同等数据量下与mysql对比聚合查询

64 阅读2分钟

背景

现有一张学生考试题目表,里面存储了学生考试题目,每个人50-100道题,学生来自不同的院系,现该表不定时组织进行全校、全班、全院系进行安全教育考试,已有数据100万,在mysql进行聚合查询、in查询等操作效率低下,现使用clickhouse进行单方面测试,模拟mysql环境下得操作在clidkdb下如何。

本地电脑配置如下:

image.png

  1. mysql 汇总数据量
select count(1) from safety_exam_ques_person ses;

第1次:totals: 1,520,211  time-consuming: 16.795s
第2次:totals: 1,520,211  time-consuming: 15.806s
第3次:totals: 1,520,211  time-consuming: 17.28s
第4次:totals: 1,520,211  time-consuming: 15.729s
第5次:totals: 1,520,211  time-consuming: 16.342s

经过5次的执行平均耗时:16.3904s
  1. clickhouse 汇总数据量
select count(1) from safety_exam_ques_person ses;

第1次:totals: 1,520,211  time-consuming: 22ms2次:totals: 1,520,211  time-consuming: 8ms3次:totals: 1,520,211  time-consuming: 9ms4次:totals: 1,520,211  time-consuming: 8ms5次:totals: 1,520,211  time-consuming: 11ms

经过10次的执行平均耗时:11.6ms6次:totals: 1,520,211  time-consuming: 8ms7次:totals: 1,520,211  time-consuming: 9ms8次:totals: 1,520,211  time-consuming: 13ms9次:totals: 1,520,211  time-consuming: 10ms10次:totals: 1,520,211  time-consuming: 8ms

经过10次的执行平均耗时:10.6ms

结论

同一环境下使用mysql、clickhouse得count汇总,发现在数据聚合分析方面clickhouse的确效率高。后面会在不同得环境在进行不同维度得测试,多方进行面验证。