Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle SQL Condition Question...
In article <6hglsp$s0d$0_at_207.17.114.24>,
"Todd Marshall"
<laz777_at_semaphore.com> wrote:
>
> Your problem is the 'not in' part of the
query. It's always much faster to
> find out if something 'is' in a table
rather than not in a table. Without
> some background on your application, I
can't provide you with a reasonable
> alternative though....
>
> Bhavesh
Gosar wrote in message <6hg4p8$se0$1_at_engnews2.Eng.Sun.COM>...
> >Hi,
> >
> >I
have 2 tables
> >
> >tab1 tab2
> >==== ====
> >.. ..
> >.. ..
> >f1 f2
>
>.. ..
> >.. ..
> >
> >Both the tables above contain approx. 60,000 Records
> >and have indexes on f1 and f2.
> >
> >I have an SQL which is the foll..
>
>
> >Insert into tab3 ( select * from tab1 where tab1.f1 not in
> > (select
distinct tab2.f2 from tab2));
> >
> >The problem is this SQL takes around
40-45 hours to execute...
> >
> >Am i missing something here...Or any
Workarounds Possible...??
> >
> >TIA,
> >Bg
> >
>
Seems like I remember
seeing a tip somewhere that doing a
NOT EXISTS is quicker than a NOT IN. (I
couldn't find the
material to verify.) Try rewriting the insert
subquery as
follows:
select *
from tab1
where not exists
(select 'x'
from tab2
where tab1.f1 = tab2.f2)
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Tue Apr 21 1998 - 00:00:00 CDT
![]() |
![]() |