Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

Free Oracle Tips

HTML Text

 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB   


 

 

 


 

 

 
 

IN vs. EXISTS SQL

Oracle Tips by Burleson Consulting

March 15, 2010


Question:  I don’t understand when I should use an IN subquery versus an EXISTS subquery.  I have tried it both ways and I get the same results, and both run fast. 

Answer:  As we know, SQL is declarative and there are many equivalent ways to write a query that gives the same results. 

This is especially true for using the IN vs. the EXISTS clause.  The Oracle documentation notes that:

“If the selective predicate is in the subquery, then use IN. If the selective predicate is in the parent query, then use EXISTS.”

Another rule of thumb was that if the subquery produced a relatively small result set, you should use IN subquery rather and an EXISTS subquery.

Prior to Oracle 10g this was a big issue and you could get a really bad execution plan if you used an IN subquery instead of an EXISTS subquery.

However, the Oracle optimizer has evolved, and as of Oracle 10g the execution plans will be identical for both IN and EXISTS subqueries.


 

 

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2012 

All rights reserved.

Oracle ? is the registered trademark of Oracle Corporation.