Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: MINUS VS NOT IN

Re: MINUS VS NOT IN

From: Saurabh Sharma <saurabhs_at_fcsltd.com>
Date: Thu, 08 Feb 2001 21:42:08 -0800
Message-ID: <F001.002AFF4C.20010208212525@fatcity.com>

HI,
the answer to ur querry lies with the fact that 'minus' takes less sort's in memory. try finding it out with the autotrace command. and also due to less sorts in memory it has less no of rows processed for the same result then 'not in'
one more thing is for any querry it sends less amount of data to client via sql*net
i feel ur question is answered.
saurabh
----- Original Message -----
To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> Sent: Friday, February 09, 2001 2:33 AM

> Hello all.
>
> I read a question concerning the use of the MINUS function earlier and I
had
> not heard of it before today. After some experimenting with it, I was
quite
> amazed at the speed of this function compared to using NOT IN.
>
> Considering the following:
>
> Query One
>
> select distinct icons from inpatient
> minus select distinct icons from ptca;
>
> Query 2
>
> select distinct icons from inpatient
> where icons NOT IN(select distinct icons from ptca)
>
> Query number one began to run in about 5 seconds whereas query 2 took
> forever to run. My question is why is the MINUS so much faster?
>
> My understanding of the NOT IN is that it probably builds the record set
in
> the second part of the SQL query each time it comes to a new icons number
in
> the first part of the query. Therefore, if there are one thousand records
to
> be searched, it probably builds the record set one thousand times. Is this
> correct? If so, how does the MINUS function build and compare the record
> set?
>
> And finally, where do I get these wonderful little tidbits? Would a SQL
> tuning book exist that might talk about the strengths and limitations of
> different functions? I really appreciate your time and input.
>
> Petre Hazelton
> Halifax, Nova Scotia CANADA
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Peter Hazelton
> INET: peterhazelton_at_hotmail.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Saurabh Sharma
  INET: saurabhs_at_fcsltd.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Feb 08 2001 - 23:42:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US