Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 9th, 2011, 03:20 AM
jst666 jst666 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Kurvi
Posts: 490 jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 56 m 39 sec
Reputation Power: 184
Updating millions of rows in a batch

Sooo, I have a table which has plenty of rows. In production, I would estimate it to be from 30 millions to 300 millions. I need to update on column (flag) in all the rows (created before certain date).

Now saying just:
Code:
UPDATE MyTable SET flag = 3 WHERE created < to_date('2010-10-08 23:59:59', 'YY-MM-DD HH24:MI:SS');
COMMIT;

Does not seem like a good idea - the commit-buffer would become too big.

I will write a PL/SQL script for this. The question is, whether I should:
a) Update each row separately, and commit after every 10000 rows. ( WHERE RowId = [rowId] )
b) Update 10000 rows with set of dates ( WHERE rowId > [some_row_id] AND RowId < [some_row_id_2]

In the latter example the some_row_ids would naturally be fetched. The rowIds come from sequence. So which one would be more effective?

I am not too familiar with PL/SQL or Oracle for that matter.

thanks,
J
__________________
Gabba Gabba Hey

Reply With Quote
  #2  
Old November 9th, 2011, 03:35 AM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,685 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 53 m 13 sec
Reputation Power: 284
What exactly do you think that a "commit buffer" is? There is no such thing in Oracle.

Are you referring to the "UNDO Tablespace"?

Oracle performs best when you commit your transaction when it needs to be. Committing in chunks slows down your process and consumes more resources.

If your UNDO is to small to handle that UPDATE then you have to adjust your UNDO size.
You should not not adjust your transaction handling.

See what Tom Kyte says on this topic:

http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:4951966319022
Comments on this post
jst666 agrees!

Reply With Quote
  #3  
Old November 9th, 2011, 03:55 AM
jst666 jst666 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Kurvi
Posts: 490 jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level)jst666 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 10 h 56 m 39 sec
Reputation Power: 184
Thanks for the link. In my situation I could do commit after every update, the integrity is not an issue - only performance. There has been a situation before where a script had taken a very long time to run, and there has been some issue that the data to be updated had been too old to perform a commit.

Just to clarify, the integrity is not an issue because all records before a certain date need to be updated. There will not be a need for rollback. Unless there is a grave error in the script - so it has to be tested properly.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Updating millions of rows in a batch

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap