update statement [message #243557] |
Thu, 07 June 2007 13:51 |
jinga
Messages: 116 Registered: January 2003
|
Senior Member |
|
|
UPDATE NP N
SET (NP,NP_SOURCE,UPDATE_DATETIME)
= (SELECT S.NP, S.NP_SOURCE,SYSDATE
FROM TEMP_PRICE S
WHERE S.ITEM_SID = N.ITEM_SID
AND S.INDEX_SID = N.INDEX_SID
AND S.TV_SID = N.TV_SID
AND S.iRM = N.IRM)
WHERE item_sid in ( select item_sid from temp_net_price);
the above update takes very long..
could any one tell me what's wrong with this..
|
|
|
Re: update statement [message #243560 is a reply to message #243557] |
Thu, 07 June 2007 13:59 |
|
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
>could any one tell me what's wrong with this..
We can guess because you've posted minimal information.
OS Name & version?
Oracle version to 4 decimal places.
Post EXPLAIN_PLAN
Post DESC of all 3 tables involved.
Are statistics current; especially for "temp_net_price" table?
Why is "temp" table actually included?
How many rows in each table?
[Updated on: Thu, 07 June 2007 14:00] by Moderator Report message to a moderator
|
|
|
|
|
Re: update statement [message #244120 is a reply to message #243557] |
Mon, 11 June 2007 11:40 |
jinga
Messages: 116 Registered: January 2003
|
Senior Member |
|
|
UPDATE (SELECT N.NET_PRICE,N.NET_PRICE_SOURCE,UPDATE_DATETIME,
S.NET_PRICE as NEW_NET_PRICE, S.NET_PRICE_SOURCE as NEW_NET_PRICE_SOURCE,SYSDATE AS NEW_UPDATE_DATETIME
FROM TEMP_NET_PRICE S, NET_PRICE N
WHERE S.ITEM = N.ITEM
AND S.INDEX = N.INDEX
AND S.TREE = N.TREE
AND S.IRM = N.IRM )
SET NET_PRICE = NEW_NET_PRICE,
NET_PRICE_SOURCE = NEW_NET_PRICE_SOURCE,
UPDATE_DATETIME = NEW_UPDATE_DATETIME;
I tried to do the above. both net_price & temp_net_price has unique key declared on (item,index, tree, irm). Still took about 10 minutes to update 500,000 rows..
|
|
|
|
Re: update statement [message #244433 is a reply to message #243557] |
Tue, 12 June 2007 15:15 |
jinga
Messages: 116 Registered: January 2003
|
Senior Member |
|
|
explain plan
UPDATE STATEMENT () [NULL]
UPDATE () NET_PRICE
HASH JOIN () [NULL]
TABLE ACCESS (FULL) TEMP_NET_PRICE_ANU
TABLE ACCESS (FULL) NET_PRICE
net_price has 5 million records. temp_net_price has about 560,000 records. both temp_net_price & net_price has unique key declared on all four columns (item,index,tree,irm).
Ananthi
|
|
|
Re: update statement [message #244438 is a reply to message #244433] |
Tue, 12 June 2007 15:47 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
I've never seen an explain plan look like that, so I am just guessing...do you have up to date statistics, or any statistics at all?
|
|
|
|
Re: update statement [message #244451 is a reply to message #244439] |
Tue, 12 June 2007 22:12 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
I agree with Kevin. The plan is as expected - no surprises. That's probably how long it takes to update 500K rows.
10mins is quite reasonable depending on hardware and configuration.
Ross Leishman
|
|
|