select subquery cause mysql server to be unresponsive

Posted by Xiao on Stack Overflow See other posts from Stack Overflow or by Xiao
Published on 2013-11-06T03:45:14Z Indexed on 2013/11/06 3:53 UTC
Read the original article Hit count: 165

Filed under:
|
|
DELETE FROM item_measurement
WHERE measurement_id IN (
   SELECT (-id) AS measurement_id
   FROM invoice_item
   WHERE invoice_id = 'A3722'
)

I've really tried hard to find what's wrong with the code. I tried to run this in a php page, which doesn't respond. I also tried the same line in phpmyadmin, infinite spinning circle and I had to restart the server(MAMP on Mac 10.9). No error was given in browser/

If I run the delete and select separately, they both finish very quickly. I don't think it's a performance issue because the separate run took < 0.1 sec each.

Thanks for any help in advance.

Edit:

I also found that a simple select statement will also suspend mysql:

select *
    from item_measurement
    where measurement_id in 
    (select -id from invoice_item where invoice_id='A3722')

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql