|
|
|
|
|
Re: Need a query for updating a table with 1 billion records [message #331662 is a reply to message #331660] |
Fri, 04 July 2008 07:42 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
Updating 10 rows in a table with 10 zillion rows, selecting the rows by means on an index is no slower than updating 10 rows in a 1000-records table.
Provide us with more details about the update that needs to be faster.
Adding a column with a default value can mean different things:
- existing rows get a null value
- existing rows get the default value
- existing rows get a value, based on their contents.
Updating a billion records simply WILL take time.
|
|
|
|
|
Re: Need a query for updating a table with 1 billion records [message #331671 is a reply to message #331668] |
Fri, 04 July 2008 08:35 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Have you dropped the requirement to have a default value for the field, or did you forget to include that in this post.
It would be quickest, if you can guarantee that no one will change the table while you're doing this, to add the constraint as ENABLE NOVALIDATE as this will not require the Db to check every single row for compliance with the constraint.
|
|
|
Re: Need a query for updating a table with 1 billion records [message #331672 is a reply to message #331668] |
Fri, 04 July 2008 08:49 |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
Quote: | Note: I want to update the above said table more quickly
|
You could try the new hint provided by oracle /*+ run_very_fast_update */ . Try it out and see if that is of any help to you. Also please note making your post in bold is very useful rather than following the forum guidelines and giving some pointless information like
a) oracle version
b) Any indexes
c) What have you tried so far
These information are completely pointless to add along with your requirement.
So as I mentioned earlier try the hint which I have provided and see if that is of any help to you.
Regards
Raj
[Edit:] Typo
[Updated on: Fri, 04 July 2008 08:50] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Need a query for updating a table with 1 billion records [message #331975 is a reply to message #331962] |
Mon, 07 July 2008 01:34 |
rkmbala
Messages: 7 Registered: July 2008 Location: Chennai
|
Junior Member |
|
|
Hi Frank,
I have checked with CTAS for 2000000 records. It is taking 3 mins.
I have following function to create and update the column with value 'N'
set serveroutput on
create or replace function updstatus(s varchar)
return varchar2 is
x varchar2(1);
begin
x:='N';
return(x);
end;
Then I had put following create statement to create the new table with CTAS.
create table t2 as select OWNER,NAME,TYPE,LINE,TEXT,DUMMY,updstatus(DUMMY)status from t1;
From the above statement I got the table with new column called status with value 'N'.
Suppose I'l use the above CTAS command what about the other objects related to that table?(ex. Index,...etc)
Bala
[mod-edit] BOLD removed.
[Updated on: Mon, 07 July 2008 07:51] by Moderator Report message to a moderator
|
|
|
|
Re: Need a query for updating a table with 1 billion records [message #331980 is a reply to message #331975] |
Mon, 07 July 2008 02:02 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
3 minutes for 2 million rows and you complain that it is slow?
How many rows per second do you want?
And how did you limit that to 2 million?
Like Michel said, why on earth do you use that idiotic function?
Why not simply ..as select (col1, col2, 'N') from old_table
How long did the addition of the column plus the update take ?
|
|
|
|
|
Re: Need a query for updating a table with 1 billion records [message #331984 is a reply to message #331982] |
Mon, 07 July 2008 02:33 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
Try it with nologging.
Again: how long does the update of the original table take?
Copy that table to your dev-environment; how else would you ever be able to test?!
Quote: | I need to reduce that time into 50 seconds.
|
Based on what? Some PHB stating that the overall change should not exceed 7 hours?
If so, let him suggest you what to do and tell him in the future it would be great to not touch such big tables anymore..
|
|
|
|
|