将行转置为列时出现内存不足错误

时间:2018-04-06 10:43:06

标签: mysql out-of-memory group-concat

我有一个像

这样的查询
create table table1 (unique i1 (col1,col2))
select
  col1,
  col2,
  group_concat(distinct case when type=3 then value end order by value desc separator ',') col3,
  group_concat(distinct case when type=4 then value end order by value desc separator ',') col4,
  group_concat(distinct case when type=5 then value end order by value desc separator ',') col5,
  ...
  group_concat(distinct case when type=N then value end order by value desc separator ',') colN
from table2 
group by col1,col2
order by null

它运行正常,但如果N“太高”(超过50列),它会在64位服务器上发出内存错误,内存为16GB

我应该检查哪些变量?

0 个答案:

没有答案