Geeks Talk

Prepare for your Next Interview




IN operator in Oracle SQL

This is a discussion on IN operator in Oracle SQL within the SQL forums, part of the Databases category; Hi, I have one doubts in using the IN operator in the subquery from the performance point of view. If I use the IN operator, somebody is saying that it ...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-28-2008
Junior Member
 
Join Date: Oct 2006
Location: chennai
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ily_saravanan is on a distinguished road
IN operator in Oracle SQL

Hi,

I have one doubts in using the IN operator in the subquery from the performance point of view. If I use the IN operator, somebody is saying that it should not be used, instead exists operator can be used.

Please let me know if any body knows that why we should not use IN operator

Thanks in advance

Regards,
Saravanan.P
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-29-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: IN operator in Oracle SQL

Quote:
Originally Posted by ily_saravanan View Post
Hi,

I have one doubts in using the IN operator in the subquery from the performance point of view. If I use the IN operator, somebody is saying that it should not be used, instead exists operator can be used.

Please let me know if any body knows that why we should not use IN operator

Thanks in advance

Regards,
Saravanan.P

IN or EXISTS which gives better performance depends upon the situation.

While using IN , optimizer runs subquery first and then joins it with main dataset. Table in the subqery is small and table in the main query is large then IN usaully makes sense.

Using EXISTS, optimizer runs main query first and then applies dataset to the subquery. If the main table size is small and subquery table size is large then EXISTS usually makes
sense.

But in general IN is slower as the sub query need to be resolved before it can be tested where as Exists fire off the equivalent query as soon as single row is returned.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Java templates, operator overloading ansahahmed OOPS 0 03-03-2008 02:06 PM
C++ Operator Overloading Part II Lokesh M C and C++ 1 12-28-2007 02:21 AM
Using LIKE operator in multiple condition Sant_parkash SQL 4 11-29-2007 02:47 AM
Operator OverLoading Code vinodjallapally Java 1 08-31-2007 07:45 AM
Operator Overloading sripri C and C++ 2 12-11-2006 10:12 AM


All times are GMT -4. The time now is 11:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved