March 10th, 2013, 01:13 PM
Join Date: Mar 2013
Time spent in forums: 25 m 6 sec
Reputation Power: 0
Subquery slows down execution when no rows returned...
I have the following, which performs nicely when the subquery returns records:
FROM `mydb`.`dataload` sb
FROM `mydb`.`domain` dm
INNER JOIN `mydb`.`set` st ON dm.`set_id` = st.`set_id`
WHERE st.set_id = 6
However, when the subquery IN (... Subquery ...) returns no rows, it takes ages to execute. The subquery, when returning rows, is not expected to give more than 25 values. The master query selects from the dataload table, which contains 40M records...