Tuesday, November 22, 2011

Is JOIN between tables is better than using IN operator?

PROBLEM:
Is JOIN between tables is better than using IN operator?

SOLUTION:
The query optimizer is better when using JOIN and not IN operator. When using IN operator the following query:


Select *
from T1
where x in (select y from T2)


is typically processed as:


Select *
from T1, (select distinct y from t2) t2
where t1.x = t2.y


The sub query is evaluated, distanced, indexed (or hashed or sorted) and then joined to the original table.

If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!


1 comment:

  1. Every website is identified by its own unique domain name. The domain name serves as your site's address on the internet. Ideally, it should match your company or business name or your website's name so that it's easier to find on the web. website development Company dubai

    ReplyDelete