douyi4991 2017-11-04 00:38
浏览 49
已采纳

动态地将内存分配给列的MySQL查询

I have this query:

SELECT DISTINCT(po.mark) franquicia, COUNT(po.id) failures, GROUP_CONCAT(po.log_transaction SEPARATOR ';') logs, DATE(po.created) fecha
FROM pagos_onlines AS po
INNER JOIN usuarios_tokens AS ut ON po.usuario_token = ut.id
WHERE status = 'REJECTED'
AND created > '2017-10-03 11:00:01'
GROUP BY fecha, franquicia;

The problem is that log_transaction is a type BLOB in the table and it stores JSON data, so the field "logs" should be a huge string with concatenated JSONs. When I run this query only one and a half JSON appeared in the field "logs", so my guess is that the memory for that field runs out of space.

Is there a way to allocate memory on the fly for a specific column when running a MySQL SELECT query?

  • 写回答

2条回答 默认 最新

  • dongwen5019 2017-11-04 20:21
    关注

    This query almost certainly throws a warning about the data being cut by GROUP_CONCAT. If you are using a client or library that ignores warnings, you can run the query SHOW WARNINGS; immediately after running your query, and confirm that this warning is present.

    To resolve this, you need to increase the value of the system variable @@GROUP_CONCAT_MAX_LEN to get longer results without truncation.

    The default value is only 1024 (bytes, not characters, according to the documentation). You can change this in global config or change it in your session before running this query.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用