文章目录
![在这里插入图片描述](https://img-blog.csdnimg.cn/49653433dee244309aa67d4e8951cf29.jpeg)
1.概述
clickhouse报错:Memory limit (for query) exceeded:would use 9.37 GiB (attempt to allocate chunk of 301989888 bytes), maximum: 9.31 GiB
分析:
- max_memory_usage指定单个SQL查询在该机器上面最大内存使用量
- 除了些简单的SQL,空间复杂度是O(1) 如:
select count(1) from table where column=value
select column1, column2 from table where column=value
凡是涉及group by, order by, distinct, join这样的SQL内存占用不再是O(1)
解决:
1: max_bytes_before_external_group_by
2: max_bytes_before_external_sort
3: uniq / uniqCombined / uniqHLL12
4: Join时小表放到右边, “右表广播” ^v