I have this query to retrieve rows from table r which do not have a corresponding entry in the table ra.
This one is taking about 8 seconds to execute.Code:SELECT name, r_id FROM r WHERE r_id NOT IN (SELECT r_id FROM ra GROUP BY r_id);
On the other hand, this query
is taking less than a second.Code:SELECT r.name, r.r_id FROM r LEFT JOIN ra on r.r_id = ra.r_id WHERE ra.r_id is NULL;
Can you explain the reason for the difference in time taken?
Thank you.




Reply With Quote