<p>Using Oracle 10g, accessed via Perl DBI, I have a table with a few tens of million rows being updated a few times per second while being read from much more frequently form another process.</p>

<p>Soon the update frequency will increase by an order of magnitude (maybe two).
Someone suggested that committing every N updates instead of after every update will help performance.</p>

<p>I have a few questions:</p>

<ul>
<li>Will that be faster or slower or it depends (planning to benchmark both way as soon as can get a decent simulation of the new load)</li>
<li>Why will it help / hinder performance.</li>
<li>If "it depends ..." , on what ?</li>
<li>If it helps what's the best value of N ?</li>
<li>Why can't my local DBA have an helpful straight answer when I need one? <br />(Actually I know the answer to that one) :-) </li>
</ul>

<blockquote>
  <p>EDIT:</p>
  
  <p>@codeslave : Thanks, btw losing
  uncommited changes is not a problem, I
  don't delete the original data used
  for updating till I am sure everything
  is fine , btw cleaning lady did
  unplugs the server, TWICE :-)</p>
  
  <p>Some googling showed it might help
  because of issue related to rollback
  segments, but I still don't know a
  rule of thumb for N every few tens ?
  hundreds? thousand ?</p>
  
  <p>@diciu : Great info, I'll definitely
  look into that.</p>
</blockquote>

[{'answer_id': 33227, 'author': 'BIBD', 'author_id': 685, 'author_profile': 'https://Stackoverflow.com/users/685', 'pm_score': 0, 'selected': False, 'text': "<blockquote>\n  <p>Faster/Slower?  </p>\n</blockquote>\n\n<p>It will probably be a little faster. However, you run a greater risk of running into deadlocks, losing uncommitted changes should something catastrophic happen (cleaning lady unplugs the server), FUD, Fire, Brimstone, etc.</p>\n\n<blockquote>\n  <p>Why would it help?  </p>\n</blockquote>\n\n<p>Obviously fewer commit operations, which in turn means fewer disk writes, etc.</p>\n\n<blockquote>\n  <p>DBA's and straight answers?   </p>\n</blockquote>\n\n<p>If it was easy, you won't need one.</p>\n"}, {'answer_id': 33246, 'author': 'diciu', 'author_id': 2811, 'author_profile': 'https://Stackoverflow.com/users/2811', 'pm_score': 3, 'selected': True, 'text': '<p>A commit results in Oracle writing stuff to the disk - i.e. in the redo log file so that whatever the transaction being commited has done can be recoverable in the event of a power failure, etc.\nWriting in file is slower than writing in memory so a commit will be slower if performed for many operations in a row rather then for a set of coalesced updates.</p>\n\n<p>In Oracle 10g there\'s an asynchronous commit that makes it much faster but less reliable: <a href="https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6158695.html" rel="nofollow noreferrer">https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6158695.html</a></p>\n\n<p>PS I know for sure that, in a scenario I\'ve seen in a certain application, changing the number of coalesced updates from 5K to 50K makes it faster by an order of magnitude (10 times faster).</p>\n'}, {'answer_id': 33316, 'author': 'stevechol', 'author_id': 2981, 'author_profile': 'https://Stackoverflow.com/users/2981', 'pm_score': 1, 'selected': False, 'text': "<p>Reducing the frequency of commits will certainly speed things up, however as you are reading and writing to this table frequently there is the potential for locks.  Only you can determine the likelihood of the same data being updated at the same time.  If the chance of this is low, commit every 50 rows and monitor the situation.  Trial and error I'm afraid :-)</p>\n"}, {'answer_id': 33323, 'author': 'BIBD', 'author_id': 685, 'author_profile': 'https://Stackoverflow.com/users/685', 'pm_score': 0, 'selected': False, 'text': '<p>If you "don\'t delete the original data used for updating till [you are] sure everything is fine", then why don\'t you remove all those incremental commits in between, and rollback if there\'s a problem?  It sounds like you effectively have built a transaction systems on top of transactions.</p>\n'}, {'answer_id': 33352, 'author': 'Pat', 'author_id': 238, 'author_profile': 'https://Stackoverflow.com/users/238', 'pm_score': 0, 'selected': False, 'text': "<p>@CodeSlave your your questions is answered by @stevechol , if i remove ALL the incremental commits there will be locks. I guess if nothing better comes along I'll follow his advice pick a random number , monitor the load and adjust accordingly. While applying @diciu twaks.</p>\n\n<p>PS: the transaction on top of transaction is just accidental, I get the files used for updates by FTP and instead of deleting them immediately I set a cron job to deletes them a week later (if no one using the application has complained) that means if something goes wrong I have a week to catch the errors.</p>\n"}, {'answer_id': 66995, 'author': 'David Aldridge', 'author_id': 6742, 'author_profile': 'https://Stackoverflow.com/users/6742', 'pm_score': 1, 'selected': False, 'text': '<p>As well as reducing the commit frequency, you should also consider performing bulk updates instead of individual ones.</p>\n'}]
['https://Stackoverflow.com/questions/33204', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/238/']