各位帮我看看那有没有优化的可能了。这个sql在测试环境需要五六秒钟,正式环境直接超时无了
SELECT
d.AREANO,
SUM(c.ORDERQTY) - SUM(c.DELIQTY) num
FROM
db.TBSOYF012 c
LEFT JOIN db.TBSOYF011 b ON
c.compId = b.compId
AND b.orderNo = c.orderNo
LEFT JOIN db.TBSBYF01 a
ON
a.COMPID = b.COMPID AND a.TRANSPORTWAYNO = b.transType
LEFT JOIN DB.TBSHYF18 d ON
c.compId = d.compId
AND a.AREANO = d.SEQNO
WHERE
c.compId = 'yf'
AND b.transType = 'T'
AND c.CREDATE <= '20200928'
AND c.CREDATE >= '20200928'
AND b.PRODTYPE LIKE 'H%'
AND c.STATUS != 'X'
GROUP BY
d.AREANO