Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Speedup the dml ??
Hi.
I think that in your case Oracle performs FULL table scan for table A ( 600K rows ) and for each one it's making SELECT from table B ( by unique index scan ). In 540K cases it's not necessary, because no corresponding row exists in table B.
Try doing it the other way :
BEGIN
FOR b_rec IN ( SELECT * FROM b ) LOOP
UPDATE a SET c5 = b_rec.c5 WHERE c1 = b_rec.c1 AND c2 = b_rec.c2 AND c3 = b_rec.c3 AND c4 = b_rec.4;
HTH. Michael.
If possible - post results ( before and after ).
In article <MPG.13617895ac05bf43989683_at_news.gcn.net.tw>,
feib <agi_at_feib.com.tw> wrote:
> Hello, there
> I have two tables a,b ( a with 600000 records, b 60000 records)
> Both a and b have the same columns c1 c2 c3 c4 c5.
> I want to update a's c5 by b's c5 for the same key value c1-c4.
> So,I create two unique indexies on a(c1,c2,c3,c4) and b
(c1,c2,c3,c4).
>
> update a
> set c5 = ( select c5
> from b
> where a.c1=b.c1
> and a.c2=b.c2
> and a.c3=b.c3
> and a.c4=b.c4 );
>
> Are there any better statement ( like EXISTS,or any hint to
speedup) ??
> Any ideas ??
>
> Rgds,
> Agi Chen
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Apr 14 2000 - 00:00:00 CDT