Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Optimal COMMIT frequency towards Batch DMLs

Re: Optimal COMMIT frequency towards Batch DMLs

From: Daniel W. Fink <optimaldba_at_yahoo.com>
Date: Tue, 22 Apr 2003 07:41:45 -0800
Message-ID: <F001.00586D44.20030422074145@fatcity.com>


A commit will post a commit record to the log buffer and force LGWR to write all pending redo records (including the commit record) to the active redo log. The data blocks that the process has modified may have already been written to the datafiles, if the buffer cache needs space.

Redo logs do not fill up and cause Snapshot Too Old. STO is related to Rollback/Undo.

Having a single commit in a batch job can cause the process to fail and also cause other processes to fail. Having too frequent commits in a batch job can cause the process to fail and also cause other processes to fail.

How do you decide the proper commit frequency? Try to find logical boundaries in the batch, like customer, time, product, etc. If you need to refer to data that may have been updated by the process, close and reopen the cursor to avoid a Fetch Across Commits.

Check out the papers/presentations on UNDO and Snapshot Too Old at www.optimaldba.com and www.evdbt.com. They will explain what occurs and provide some good info on commit frequency.

-- 
Daniel W. Fink
http://www.optimaldba.com

IOUG-A Live! April 27 - May 1, 2003 Orlando, FL
   Thursday, May 1 1:00pm - 2:00pm - Automatic Undo Internals


rgaffuri_at_cox.net wrote:


>try to do one commit when batch is done. All commit does is flag the checkpoint background process to execute the DBWR. Its automatically written to redo logs which you do not control.
>
>Only commit more often if:
>1. Need to release a lock so another process can use it(ie deadlock or another batch needs it)
>2. redo logs fill up and you cant make them larger and get the dreaded snapshot too old error(could be wrong on this one)
>other than that. no reason to commit more than once per transaction.
>
>DBWR is a much more expensive disk write than the redo log writer since it writes it in a more structured way in order to optimize data retrieval.
>
>
>
>
>>From: "VIVEK_SHARMA" <VIVEK_SHARMA_at_infosys.com>
>>Date: 2003/04/22 Tue AM 09:16:37 EDT
>>To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
>>Subject: RE: Optimal COMMIT frequency towards Batch DMLs
>>
>>
>>COMMIT is issued after DMLs corresponding to 300 application Transactions ,
>>each of Transaction size about 5 KB . Thus COMMIT done after about 1.5 MB
>>
>>NOTE - DML with Arrays are NOT used by our application .
>>
>>Is the Optimal Commit frequency based on Size , Time between Commits ?
>>
>>Which Sub-operations on COMMIT have MAX. overhead which are thereby reduced by reducing the frequency of Commits ?
>>
>>Thanks
>>
>>
>>-----Original Message-----
>>Sent: Monday, April 21, 2003 10:29 PM
>>To: Multiple recipients of list ORACLE-L
>>
>>
>>Like many, many questions on this list, this one also 'depends'. This
>>really depends on your business needs and on your resources (mostly
>>space for large enough rollback segs or undo space).
>>I'm usually inclined to limit commits when possible. If I've got a job
>>which updates records and my rollback space and segment size will
>>accommodate it, I will first entertain the idea of updating all affected
>>records in one set. However, I realize I must be prepared to tolerate a
>>lengthy rollback in the event of a failure. So, depending on the
>>circumstances, I may do this update in sets based on date or some other
>>criteria.
>>You may also have multiple sets of data which get updated based on
>>different criteria and you may want to commit after each set if you want
>>set A to remain even if set B has problems. You may also have a job
>>where it is all or nothing where all changes must be rolled back if any
>>fail.
>>Committing too frequently can also become troublesome. I've seen a
>>procedure which committed for each iteration of a loop and caused itself
>>ORA-01555 errors.
>>
>>I'd say there's probably not a rule or a document which will say with
>>any certainty how frequent commits should be in batch. However, what I
>>would recommend is to search for a paper on what takes place when data
>>is committed (or one really good source is Jonathon Lewis' book
>>"Practical Oracle 8i", committing data is covered very early in his book
>>/ how it affects data blocks, blocks in redo, blocks in rollback, etc.)
>>and that should 'guide' you on making a decision for each of your batch
>>jobs depending on the circumstances. One thing for certain is that the
>>more frequently a job commits, the more work it is doing and avoiding
>>extra work is good where the database is concerned.
>>
>>
>>
>>
>>
>>>>>VIVEK_SHARMA_at_infosys.com 04/21/03 10:21AM >>>
>>>>>
>>>>>
>>How may the Optimal COMMIT frequency in Batch DML Operations be
>>determined ?
>>
>>What is the Spirit behind the same ?
>>
>>Any Links , Docs please ?
>>
>>Thanks
>>
>>
>>
>>--
>>Please see the official ORACLE-L FAQ: http://www.orafaq.net
>>--
>>Author: VIVEK_SHARMA
>> INET: VIVEK_SHARMA_at_infosys.com
>>
>>Fat City Network Services -- 858-538-5051 http://www.fatcity.com
>>San Diego, California -- Mailing list and web hosting services
>>---------------------------------------------------------------------
>>To REMOVE yourself from this mailing list, send an E-Mail message
>>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>>the message BODY, include a line containing: UNSUB ORACLE-L
>>(or the name of mailing list you want to be removed from). You may
>>also send the HELP command for other information (like subscribing).
>>
>>--
>>Please see the official ORACLE-L FAQ: http://www.orafaq.net
>>--
>>Author: Darrell Landrum
>> INET: DLANDRUM_at_zalecorp.com
>>
>>Fat City Network Services -- 858-538-5051 http://www.fatcity.com
>>San Diego, California -- Mailing list and web hosting services
>>---------------------------------------------------------------------
>>To REMOVE yourself from this mailing list, send an E-Mail message
>>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>>the message BODY, include a line containing: UNSUB ORACLE-L
>>(or the name of mailing list you want to be removed from). You may
>>also send the HELP command for other information (like subscribing).
>>
>>--
>>Please see the official ORACLE-L FAQ: http://www.orafaq.net
>>--
>>Author: VIVEK_SHARMA
>> INET: VIVEK_SHARMA_at_infosys.com
>>
>>Fat City Network Services -- 858-538-5051 http://www.fatcity.com
>>San Diego, California -- Mailing list and web hosting services
>>---------------------------------------------------------------------
>>To REMOVE yourself from this mailing list, send an E-Mail message
>>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
>>the message BODY, include a line containing: UNSUB ORACLE-L
>>(or the name of mailing list you want to be removed from). You may
>>also send the HELP command for other information (like subscribing).
>>
>>
>>
>>
>
>
>
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Daniel W. Fink INET: optimaldba_at_yahoo.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Received on Tue Apr 22 2003 - 10:41:45 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US