Join Algorithm in ClickHouse
ClickHouse 目前共实现了 6 种连接算法 [1]:
- Direct join[2]
- Hash join[3]
- Parallel hash join[3:1]
- Grace hash join[3:2]
- Full sorting merge join[4]
- Partial merge join[4:1]
用于可以自由选择连接算法。
它们的特性对比如下:
选择连接算法
有三个需要考虑的因素:
性能
内存
如果内存比性能更重要,可以:
连接类型支持
ClickHouse 连接类型 支持的连接算法如下图:
https://clickhouse.com/blog/clickhouse-fully-supports-joins-how-to-choose-the-right-algorithm-part5 ↩︎
https://clickhouse.com/blog/clickhouse-fully-supports-joins-direct-join-part4 ↩︎
https://clickhouse.com/blog/clickhouse-fully-supports-joins-hash-joins-part2 ↩︎ ↩︎ ↩︎
https://clickhouse.com/blog/clickhouse-fully-supports-joins-full-sort-partial-merge-part3 ↩︎ ↩︎