Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do the time of the COMMIT and ROLLBACK affect performance?

Tags:

oracle

Suppose I have a set of ID . For each ID , I will insert many records to many different tables based on the ID .Between inserting difference tables, different business checks will be called . If any checking fail , all the records that are inserted based on this ID will be ROLLBACK .This bulk insert action is done through using PL/SQL . Do the time of the COMMIT and ROLLBACK affect the performance and how does it affect ? For example , should I COMMIT after finish the process for one ID or COMMIT after finish all ID?

like image 625
Ken Chan Avatar asked Dec 07 '22 01:12

Ken Chan


1 Answers

This is not so much of a performance decision but a process design decision. Do you want the other IDs to stay in the database when you have to roll back a faulty ID?

For obvious reasons, rollback takes longer when more rows must be rolled back. Rollback usually takes longer (sometimes much longer!) than the operations that have to be rolled back. Commit is always fast in Oracle, so it probably doesn't matter how often you commit in that regard.

like image 65
Erich Kitzmueller Avatar answered May 19 '23 20:05

Erich Kitzmueller