I have a MySGL query:
UPDATE Feeds
SET Quantity = (SELECT Inventory.Quantity
FROM Inventory
WHERE Feeds.SKU = Inventory.SKU)
WHERE EXISTS (SELECT Inventory.Quantity
FROM Inventory
WHERE Feeds.SKU = Inventory.SKU);
It's working well, but very slow. The database is MySQL inodb, rows is around 50,000, to run the execution takes about half of hour. How can I decrease the execution time? Thanks in advance.
UPDATE?Feeds.SKUand/orInventory.SKU? Might anUPDATE Feeds JOIN Inventorybe better here? Try:UPDATE Feeds JOIN Inventory USING(SKU) SET Feeds.Quantity = Inventory.Quantity;. TheJOINshould take care of theWHERE EXISTS, since it won't match rows that don't have matching SKUs. I didn't test this, but I think that's right.DESCRIBE InventoryandDESCRIBE Feeds