【clickhouse】Memory limit (for query) exceeded:would use 9.37 GiB (attempt to allocate chunk of 30198

文章目录

  • 1.概述

【clickhouse】Memory limit (for query) exceeded:would use 9.37 GiB (attempt to allocate chunk of 30198_第1张图片

1.概述

clickhouse报错:Memory limit (for query) exceeded:would use 9.37 GiB (attempt to allocate chunk of 301989888 bytes), maximum: 9.31 GiB

分析:

  1. max_memory_usage指定单个SQL查询在该机器上面最大内存使用量
  2. 除了些简单的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

你可能感兴趣的:(clickhouse,clickhouse)