If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Commit

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-05, 01:06
AnilKale AnilKale is offline
Registered User
 
Join Date: Feb 2005
Posts: 118
Commit

Hi All !

let's say there is a piece of java code that performs 100,000 INSERTs (into TABLE tab1) in a loop. The db2 connection of the java program does a autocomitt. Therefore, under the current execution, it does a 100,000 commits.
In order to tune this insert program. I proposed to turn off the auto commit and commit the inserts on a frequency as defined in the code. Which I know will show a definite gain in performance.
upon further investigation, I found that the table tab1 is always going to be empty at the begining of each run. So my question to you is will I be even better off if
- I perform a CREATE TABLE with the NOT LOGGED INITIALLY clause, for every run.
- turn off auto commit
- perform one commit at the end of all INSERTs

1. Will this be the equivalent of doing a LOAD REPLACE with LOG NO ?
2. Will I be better off doing a commit at the end of all inserts (one a table created for every run using CREATE TABLE with NOT LOGGED INITIALLY) visa-vis doing only one CREATE TABLE and performing COMMITs at a regular frequency ?

thanks.
Anil

Also, could someone send me a piece of java code that does turns off the autocommit and performs commit within the program. That would save our developer's effort and trying to figure out 'how to turn off autocommit ? '
Reply With Quote
  #2 (permalink)  
Old 03-03-05, 10:36
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html#setAutoCommit(boolean)

You may want also to take a look at this:

http://java.sun.com/docs/books/tutor...chupdates.html
Reply With Quote
  #3 (permalink)  
Old 03-03-05, 12:48
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
If you don't care about the table if your transaction fails, then using NOT LOGGED INITIALLY with inserts in the same UOW should work fine. Keep in mind that you will need a backup after the inserts if you want to recover the table due to system crash or other reason when using NOT LOGGED INITIALLY.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On