
March 10th, 2013, 01:13 PM
|
|
Registered User
|
|
Join Date: Mar 2013
Posts: 3
Time spent in forums: 25 m 6 sec
Reputation Power: 0
|
|
Subquery slows down execution when no rows returned...
Hey guys,
I have the following, which performs nicely when the subquery returns records:
Code:
SELECT *
FROM `mydb`.`dataload` sb
WHERE sb.`domain`
IN (
SELECT dm.`domain`
FROM `mydb`.`domain` dm
INNER JOIN `mydb`.`set` st ON dm.`set_id` = st.`set_id`
WHERE st.set_id = 6
)
LIMIT 2000
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...
Any thoughts?
THANKS!
|