MySQL Forums
Forum List  »  Newbie

How can I index or make this code faster. The sum query is the slow point.
Posted by: Nathan Stanford
Date: March 01, 2014 05:50PM

SELECT a.ORD_ID AS Manual_Added_Orders,
a.ORD_poOrdID_List AS Auto_Added_Orders,
a.ORDPOITEM_ModelNumber,
a.ORDPO_Number,
a.ORDPOITEM_ID,
(SELECT sum(ORDPOITEM_Qty) AS ORDPOITEM_Qty
FROM orderpoitems
WHERE ORDPOITEM_ModelNumber = a.ORDPOITEM_ModelNumber
AND ORDPO_Number = 123007)
AS ORDPOITEM_Qty,
a.ORDPO_TrackingNumber,
a.ORDPOITEM_Received,
a.ORDPOITEM_ReceivedQty,
a.ORDPOITEM_ReceivedBy,
b.ORDPO_ID
FROM orderpoitems a
LEFT JOIN orderpo b ON (a.ORDPO_Number = b.ORDPO_Number)
WHERE a.ORDPO_Number = 123007
GROUP BY a.ORDPOITEM_ModelNumber,a.ORD_poOrdID_List, a.ORD_ID
ORDER BY a.ORDPOITEM_ModelNumber,a.ORD_poOrdID_List, a.ORD_ID


I did an Explain but I am not sure what to do to make a good index or how to make the sum go faster.

Options: ReplyQuote


Subject
Written By
Posted
How can I index or make this code faster. The sum query is the slow point.
March 01, 2014 05:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.