20200302

@ShiKaiWi

Plan

60min: ClickHouse

Notes

Developer

https://clickhouse.tech/docs/en/development/developer_instruction/

常用编译命令:

ninja -j 2 clickhouse-server clickhouse-client

server 启动命令:

cd ./dbms/programs/server/
../../../build/dbms/programs/clickhouse server

client 连接命令:

build/dbms/programs/clickhouse client

Architecture

没有仔细的阅读整个文档,着重浏览了 MergeTreee:

  • 和 LSM 不一样,没有 WAL 和 memtable 的结构,只有纯粹的 tree file,所以写入性能不怎么样。
  • 同时和 LSM 一样的是,存在 background merge thread,需要去做 tree 的合并,存在写放大。
  • 此外由于数据按照 block 存储,查询少量数据也没有优势,存在读放大。
  • 但是他有非常重要的特性: 查询大量数据、进行复杂的聚合操作时,性能非常好。

至于是如何这种查询场景性能优化的,ClickHouse 有两个比较重要的优化:vectorized query execution and runtime code generation,有相应的论文 可以阅读。

More