Board index » delphi » Explanation between difference INNER JOIN and an SUB-QUERY

Explanation between difference INNER JOIN and an SUB-QUERY

Hi,

Maybe a stupid question but i can't find it in my delphi-books. But can
anybody tell me
why a INNER JOIN is faster then a subquery like  "SELECT * FROM DB WHERE
(SELECT IN(----))?

Greetings and thanx,
Songbo

 

Re:Explanation between difference INNER JOIN and an SUB-QUERY


Songbo,

   SQL Server has special mechanisms specific to the INNER JOIN keywords
that enhance performance and your sub-selects generate another level of
execution the server has to handle.  Check out Books Online for more
information.

Good luck,
krf

Quote
Songbo wrote in message <91afb0$g...@bornews.inprise.com>...
>Hi,

>Maybe a stupid question but i can't find it in my delphi-books. But can
>anybody tell me
>why a INNER JOIN is faster then a subquery like  "SELECT * FROM DB WHERE
>(SELECT IN(----))?

>Greetings and thanx,
>Songbo

Re:Explanation between difference INNER JOIN and an SUB-QUERY


son...@studenten.net (Songbo) wrote in <91afb0$g...@bornews.inprise.com>:

Quote
>Hi,

>Maybe a stupid question but i can't find it in my delphi-books. But can
>anybody tell me
>why a INNER JOIN is faster then a subquery like  "SELECT * FROM DB WHERE
>(SELECT IN(----))?

Depends on your db server.  With Oracle(7.x anyways), if you don't need any
fields from the other table this is faster.

SELECT *  
  FROM TABLE1
 WHERE EXISTS (SELECT 'X'
                 FROM TABLE2
                WHERE TABLE2.F1 = TABLE1.F1)

Iman

Other Threads