在 MySQL 5.6 中总是“发送数据”

Posted

技术标签:

【中文标题】在 MySQL 5.6 中总是“发送数据”【英文标题】:Always "Sending Data" In MySQL 5.6 【发布时间】:2021-09-16 22:53:50 【问题描述】:

我正在运行此查询,但在进程列表中此状态为“正在发送数据”,我尝试使用 Maria DB 10 此查询成功运行,但在 mysql 5.6.44 中始终发送数据, 你能帮我解决这个问题吗

表格/视图 v_stock

PartName Qty Stock
A 10

tbl_cummulative

id cummulativeQty qtyOrder qtyStore partName mscode fob refreshDate
A 5 15 20 A AA 2021-01-01 2021-01-01
A 0 5 20 A AA 2021-01-02 2021-01-01
A -5 5 20 A AA 2021-01-03 2021-01-01
A -10 5 20 A AA 2021-01-04 2021-01-01
select s.partName AS partName,
group_concat(distinct c.mscode separator ',') AS model,
(select min(cum.fob) from dbbomv2.tbl_cummulative cum where cum.partName = s.partName and cum.cummulativeQty < 0) AS fob,
s.qtyStock AS qtyStock,
sum(c.qtyOrder) AS qtyOrder,
min(c.cummulativeQty) AS qtyShortage,
(
    select min(dbbomv2.tbl_cummulative.cummulativeQty) AS cummulativeQty 
    from dbbomv2.tbl_cummulative 
    where dbbomv2.tbl_cummulative.fob = (select min(cum.fob) from dbbomv2.tbl_cummulative cum where cum.partName = s.partName and cum.cummulativeQty < 0) 
    and dbbomv2.tbl_cummulative.partName = s.partName and dbbomv2.tbl_cummulative.cummulativeQty < 0
) AS qtyOrderClosest 
from (dbbomv2.v_stock s 
left join 
dbbomv2.tbl_cummulative c on(s.partName = c.partName)) 
group by s.partName 
order by c.fob is null,c.fob,s.partName

我需要这样的桌子

partName model fob qtyStock qtyOrder qtyShortage fobqtyOrderClosest
A AA 2021-01-03 20 5 -5 2021-01-03

这个 MySQL 5.6.44

这个 Maria DB 10

【问题讨论】:

检查如果缓冲区太小会显示的mysql 使用 EXPLAIN 分析两台服务器中查询的优化计划。查找所选索引和检查的行数之间的差异。 【参考方案1】:

解决,我删除此查询并在程序中运行此查询

(
    select min(dbbomv2.tbl_cummulative.cummulativeQty) AS cummulativeQty 
    from dbbomv2.tbl_cummulative 
    where dbbomv2.tbl_cummulative.fob = (select min(cum.fob) from dbbomv2.tbl_cummulative cum where cum.partName = s.partName and cum.cummulativeQty < 0) 
    and dbbomv2.tbl_cummulative.partName = s.partName and dbbomv2.tbl_cummulative.cummulativeQty < 0
) AS qtyOrderClosest

【讨论】:

以上是关于在 MySQL 5.6 中总是“发送数据”的主要内容,如果未能解决你的问题,请参考以下文章

如何在 C++ 中使用单个 APDU 发送和获取数据?

如何发送数据库内容而不是 [object Object] Discord.js + mysql

TCP Nagle算法以及延迟确认(即延迟回复ACK)的学习

MySQL 查询在迁移到 RDS 后停留在“发送数据”中 30 秒

如何从 laravel 中的控制器向部分视图发送数据?

将 POST 数据从 Android 应用程序发送到 PHP MySQL