Search code examples
mysqlsqlperformancejoinselect-query

Select ... where foo_id in (select id from ...) Efficiency


i) Between these two which one is more efficient:

Select A.* from A, B where A.b_id = B.id

or

Select A.* from A where A.b_id in (select id from B);

ii) How does Select A.* from A where A.b_id in (select id from B); really work? Is it internally translated into something like Select A.* from A, B where A.b_id = B.id or is (select id from B) evaluated for each row of A?


Solution

  • You can check this short article: http://www.mysqlperformanceblog.com/2010/10/25/mysql-limitations-part-3-subqueries/