Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to commit changes?

Tags:

sql

commit

oracle

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.

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.

I have a few questions:

  • 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)
  • Why will it help / hinder performance.
  • If "it depends ..." , on what ?
  • If it helps what's the best value of N ?
  • Why can't my local DBA have an helpful straight answer when I need one?
    (Actually I know the answer to that one) :-)

EDIT:

@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 :-)

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 ?

@diciu : Great info, I'll definitely look into that.

like image 423
Pat Avatar asked Aug 28 '08 19:08

Pat


People also ask

When should you make a commit?

Commit early, commit often If you are working on a feature branch that could take some time to finish, it helps you keep your code updated with the latest changes so that you avoid conflicts. Also, Git only takes full responsibility for your data when you commit.

When should I use git commit?

The "commit" command is used to save your changes to the local repository. Note that you have to explicitly tell Git which changes you want to include in a commit before running the "git commit" command. This means that a file won't be automatically included in the next commit just because it was changed.

How often should you commit changes to Git?

If you're using Git, then commit whenever you finish a step. I use SVN and I like to commit when I finish a whole feature, so, every one to five hours. If I were using CVS I'd do the same. Save this answer.

Should I commit changes before pull?

If you have uncommitted changes, the merge part of the git pull command will fail and your local branch will be untouched. Thus, you should always commit your changes in a branch before pulling new commits from a remote repository.


2 Answers

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. Writing 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.

In Oracle 10g there's an asynchronous commit that makes it much faster but less reliable: https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6158695.html

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).

like image 146
diciu Avatar answered Sep 22 '22 16:09

diciu


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 :-)

like image 21
stevechol Avatar answered Sep 22 '22 16:09

stevechol