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

Home -> Community -> Usenet -> c.d.o.server -> Managing transations involving thousands of records

Managing transations involving thousands of records

From: jortizclaver <jortizclaver_at_gmail.com>
Date: 28 Dec 2005 00:08:21 -0800
Message-ID: <1135757301.014711.138960@g47g2000cwa.googlegroups.com>


Hi,

My application needs to upload some thousands of records into a database. Each record insertion involves some validation process and more than one insert operation into the database. Each record is independent of each other so if one insertion fails, process can go on with the rest of the records.

In this scenario, four different ways of implementing transaction management came to my mind:

  1. Single transaction
    • Begin transaction
    • For each record
      • Insert record
      • If error, rollback and exit
    • Commit
  2. Multiple transaction
    - For each record
    • Begin transaction
    • Insert record
    • Commit/rollback
  3. Commit in blocks
    - Begin transaction
    • For each record
      • If recordN=100 then
        • Commit
        • Begin transaction
      • Insert record
      • If error, rollback and exit
    • Commit transaction
  4. Using savepoint
    - Begin transaction
    • For each record
      • Savepoint
      • Insert record
      • If error, rollback to savepoint and continue processing
    • Commit transaction
  5. Process takes too long to complete so a rollback at the end would imply to restart the process. Also, I suppose a commit of thousands of change could be really painfull for the database.
  6. The use of one transaction for each record is the easiest way to implement it but it sounds like pretty intensive for the database.
  7. This option allows me to make a commit each 100 records, so it seems like it improves the performance of the process. In the the other hand, if a record fails, I'd reject some other records valid for my system.
  8. I perceive this last one, or at least a combination between C and D, like the best one but I have some concerns about the performance of the use of the savepoints feature.

Well, someone could think I already wrote the question and the answer but I'd really appreciate any comment about this reflexions. I'm not a DBA so probably I'm wrong in more than one assumption.

Thanks in advance
Jorge Received on Wed Dec 28 2005 - 02:08:21 CST

Original text of this message

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