Seems like a basic inner join would do what you want, no? Using ANSI join syntax: select first.id from first join second on first.id=second.id; Don. On Thu, Jan 7, 2010 at 11:06 AM, Joel Slowik <jslowik@xxxxxxxxx> wrote: > 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. -- Don Seiler http://seilerwerks.wordpress.com ultimate: http://www.mufc.us -- //www.freelists.org/webpage/oracle-l