I run this query to update "domains" table based on "log" table:
UPDATE domains SET domains.mx_collected = 0 WHERE domains.domain IN (SELECT log.mail as domain_name FROM log WHERE `time` >= DATE_SUB( CURDATE( ) , INTERVAL 30 DAY ) AND `time` <= DATE_SUB( CURDATE( ) , INTERVAL 15 DAY ) group BY domain_name HAVING count(*) > 200)
While the subquery itself runs very fast (0.6 sec) with a result set of only 6 items the update never ends (not after hours). But if I run the update-query with a item list instead of a subquery it successfully ends after 0.02 seconds:
UPDATE domains SET domains.mx_collected = 0 WHERE domains.domain IN ("0815.ru","123.com","123mail.org","126.com","139.com","13hotmail.com")
Question is: why?