Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC performance

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it worth it to setAutoCommit off when I'm just doing a query ?
Pho
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a series of statements to be executed then it is worth to setAutoCopmmit to off.. Otherwise each statement will be executed as a separate Tx.
 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
But execution of the setAutoCommit depends on the underlying driver classes used also...Some of the drivers just ignore the statement.

MSM
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying. I am using Oracle 8 thin driver and found this great resource n
benchmark results testing oracle drivers using setAutoCommit off and on. Interesting read.
Cheers.
Pho
 
Roger Thornhill
Author
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion, you should almost never auto-commit. Implicit execution is generally bad, because it brings with it baggage that you don't often need. Auto-commit is safe for people unfamiliar with databases. But, for those who are comfortable with the basics, it really makes sense to commit explicitly and to perhaps commit sparingly (at some higher logical level).
For example, suppose you want to do an all-or-nothing insert of 100 rows. If one row fails, none of the other rows should be inserted. In that case, you should insert each of the rows without committing and then do the commit at the end. Not only will your batch processing work the way you want it to, but you will get much better performance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic