[thelist] SQL

Fred Jones fredthejonester at gmail.com
Sun Mar 29 09:56:24 CDT 2009

Just sharing today's lesson this Sunday morning. I tried using this:

UPDATE contact SET xxx='yyy'
 WHERE id IN (SELECT contact_id FROM temp)

and it ran on 100% CPU for a few minutes before I killed it. Then I
wrote it like this"

UPDATE contact
LEFT JOIN temp ON temp.contact_id = contact .id
SET xxx='yyy'
WHERE temp.contact_id IS NOT NULL;

and MySQL did 25K rows in a few seconds. :)

Rock on.

More information about the thelist mailing list