dai.hop
07-31-2009, 09:09 AM
Hi all,
I have the following query:
SELECT transaction_id FROM order_lines GROUP BY transaction_id HAVING SUM(amount) > 100
This returns approximatley 1000 records. Using the transaction_id's from this query I then need to perform an update. I have tried...
UPDATE order_lines SET alt_item_name = 'TEST' WHERE transaction_id IN (SELECT transaction_id FROM order_lines GROUP BY transaction_id HAVING SUM(amount) > 100)
...however this query causes the server hosting my database to become unresponsive. I'm presuming this is because the server is attempting to do 1000 full table scans or something else very inefficient?!
Does anyone know how I can modify my query to make it efficient enough to not crash the server?
Thanks!
dai.hop
I have the following query:
SELECT transaction_id FROM order_lines GROUP BY transaction_id HAVING SUM(amount) > 100
This returns approximatley 1000 records. Using the transaction_id's from this query I then need to perform an update. I have tried...
UPDATE order_lines SET alt_item_name = 'TEST' WHERE transaction_id IN (SELECT transaction_id FROM order_lines GROUP BY transaction_id HAVING SUM(amount) > 100)
...however this query causes the server hosting my database to become unresponsive. I'm presuming this is because the server is attempting to do 1000 full table scans or something else very inefficient?!
Does anyone know how I can modify my query to make it efficient enough to not crash the server?
Thanks!
dai.hop