【 TiDB 使用环境】生产环境 /测试/ PCO
【 TiDB 版本】5.7.25-TiDB-v6.1.0
【遇到的问题】
sql语句:
select
T_58CD4F.branch_name as __fcol_0,
sum(T_58CD4F.number) as __fcol_1
from (SELECT
DISTINCT
d.lines_name,
d.branch_name,
d.shop_name,
di.delivery_id,
di.sku,
di.number
from (
SELECT
d.delivery_id,
d.lines_name,
b.name AS branch_name,
s.name AS shop_name,
d.erpsource
FROM
erp_sdb_wms_delivery d
LEFT JOIN erp_sdb_ome_branch b ON b.branch_id = d.branch_id AND b.erpsource = d.erpsource
LEFT JOIN erp_sdb_ome_shop s ON s.shop_id = d.shop_id AND s.erpsource = d.erpsource
WHERE
delivery_time BETWEEN UNIX_TIMESTAMP(‘2021-01-01’) and UNIX_TIMESTAMP(DATE_ADD(‘2022-08-01’,INTERVAL 1 DAY ))
) d join ( SELECT delivery_id, bn AS sku, erpsource, number FROM erp_sdb_wms_delivery_items
WHERE 1=1
and bn in ('SOUFEEL_22','BZD008') ) di
ON di.delivery_id = d.delivery_id and di.erpsource=d.erpsource
) as T_58CD4F
where 1 = 1
group by T_58CD4F.branch_name
【问题现象及影响】
单独执行耗时是7.3秒,但是多个并发执行这个sql的时候耗时达到32秒。
观察dashboard页面,cpu使用率变高