Thursday, April 19, 2007
« Make Google Reader perty | Main | Is it time to go back to BootCamp? »
Today at work we had a brief discussion about whether using an IN or an EXISTS is more performant.  There were a couple different opinions, although most thought that EXISTS was faster.  It turns out that like most things in our wonderful software world there is not clear cut answer.  In general the below holds true:
  • If the majority of the filtering criteria are in the subquery then the IN variation may be more performant.
  • If the majority of the filtering criteria are in the top query then the EXISTS variation may be more performant.
Source: http://www.oracle-base.com/articles/misc/EfficientSQLStatements.php#Exists and this.

I assume the same holds true for SQL Server, although we're less interested in that at the moment.

 | 
Friday, April 20, 2007 3:13:05 AM (Eastern Daylight Time, UTC-04:00)
Hi Steve,

The only way to really find out this info is to test it. I've found, through painful and wasted time, that opinions or ideas of what is performant can only be determined through solid metrics.

It shouldn't take too long to write up some tests, and put together some representative data.
Monday, April 23, 2007 11:57:55 AM (Eastern Daylight Time, UTC-04:00)
Much as I'd love to take credit for this nugget of information in my article, it actually comes straight out of the manual:

http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14211/sql_1016.htm#sthref1094

Cheers

Tim...
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):