RE: Simple SQL Query

  • From: "Joel Slowik" <jslowik@xxxxxxxxx>
  • To: <panibabu.mail@xxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 7 Jan 2010 12:06:21 -0500

Had you tried?:

 

Select first.id

From first

Where not exists (select second.id

                                                From second

                                                Where second.id =
first.id)

 

From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Pani Babu
Sent: Thursday, January 07, 2010 12:04 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: Simple SQL Query

 

I have a simple SQL query which lists all the records that are not in a
second table.

select first.id from first
where first.id not in (select id from second);

As the second table is very huge, it takes a very long to process the
query.
Is there a way to rewrite the query to run it quicker?




Confidentiality Note: This electronic message transmission is intended only for 
the person or entity to which it is addressed and may contain information that 
is privileged, confidential or otherwise protected from disclosure. If you have 
received this transmission, but are not the intended recipient, you are hereby 
notified that any disclosure, copying, distribution or use of the contents of 
this information is strictly prohibited. If you have received this e-mail in 
error, please contact Continuum Performance Systems at {203.245.5000} and 
delete and destroy the original message and all copies.

Other related posts: