ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert L. Sapp" <as...@uiuc.edu>
Subject Re: Batch question.
Date Thu, 27 Jul 2006 15:08:19 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi, Jeff.<br>
<br>
It looks like I should look at setting this up in a batch.&nbsp; Basically,
I am doing the following.<br>
<br>
createInvoice<br>
createInvoiceItems in loop<br>
createBannerTransactions in loop<br>
updateInventoryItems in loop<br>
deleteShoppingCartItems in loop<br>
<br>
I have them grouped already.&nbsp; So I should have 3 sub-batches, correct?&nbsp;
Will the fact that the creates go against 3 different tables force
different sub-batches there?&nbsp; Since the batch is inside the
transaction, my error trapping should not be affected, if I understand
this right.&nbsp; By the way, I am running against a Oracle 10g DB and using
the Oracle JDBC driver.&nbsp; Since it is all working correctly right now, I
don't see adding the batch commands as a problem.<br>
<br>
I also agree that performance will vary as there are just too many
factors with each application that can affect it.&nbsp; <span
 class="moz-smiley-s1"><span> :-) </span></span><br>
<br>
Thanks for the quick response and giving me something else to look at
implementing.<br>
<br>
Al<br>
<br>
Jeff Butler wrote:
<blockquote
 cite="midc593b8750607270732k18a4d2b2mbf50b9da11a03003@mail.gmail.com"
 type="cite">
  <div>A batch may help you if you can group&nbsp;identical statements
together in your transaction.&nbsp; iBATIS calculates "sub batches" based on
the generated SQL - but you cannot mix the statements at will.&nbsp; If a
new statement is added to a batch that does not match the immediately
preceding statement, then a new sub batch is created.&nbsp; For example,
this is 4 sub-batches and should yield a performance improvement:
  </div>
  <div>&nbsp;</div>
  <div>insert into table1...</div>
  <div>insert into table1...</div>
  <div>insert into table1...</div>
  <div>update table1...</div>
  <div>update table1...</div>
  <div>update table1...</div>
  <div>insert into table1...</div>
  <div>
  <div>insert into table1...
  <div>insert into table1...</div>
  </div>
  </div>
  <div>
  <div>update table1...</div>
  <div>update table1...</div>
  <div>update table1...</div>
  <div>&nbsp;</div>
  <div>But the following&nbsp;will turn into 12 sub-batches - no performance
improvement:</div>
  <div>&nbsp;</div>
  </div>
  <div>insert into table1...</div>
  <div>update table1...</div>
  <div>insert into table1...</div>
  <div>update table1...</div>
  <div>insert into table1...</div>
  <div>update table1...</div>
  <div>insert into table1...</div>
  <div>update table1...</div>
  <div>insert into table1...</div>
  <div>update table1...</div>
  <div>insert into table1...</div>
  <div>update table1...</div>
  <div>&nbsp;</div>
  <div>Some JDBC drivers cache prepared statements and in those cases
the differences won't be so significant.&nbsp; As always with any
performance discussion, your milage may vary.</div>
  <div><br>
Jeff Butler</div>
  <div>&nbsp;</div>
  <div><br>
&nbsp;</div>
  <div><span class="gmail_quote">On 7/27/06, <b
 class="gmail_sendername">Albert L. Sapp</b> &lt;<a
 href="mailto:asapp@uiuc.edu">asapp@uiuc.edu</a>&gt; wrote:</span>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left:
1ex;">Hi,
everyone.<br>
    <br>
Did not know whether this fit in with recent question on iBatis batch<br>
support :-) , so I just sent a separate email.
    <br>
    <br>
Is there any rule-of-thumb for determining when to use batch within a<br>
transaction?&nbsp;&nbsp;I have a shopping cart application and, when the user goes<br>
through checkout, there are a number of inserts, updates and deletes
for
    <br>
each item in the cart that are performed.&nbsp;&nbsp;Right now, I just put them<br>
all between start, commit and end transaction tags.&nbsp;&nbsp;It works fine this<br>
way with rollback happening cleanly, when needed.&nbsp;&nbsp;I don't think there
    <br>
will ever be a large number of items at any one time to in a user's<br>
shopping cart, but was wondering if it is still a "best practice" to put<br>
inside batch tags as well.<br>
    <br>
Always try to keep up on "best practices".&nbsp;&nbsp;;-)
    <br>
    <br>
Thanks,<br>
    <br>
Al<br>
    <br>
  </blockquote>
  </div>
  <br>
</blockquote>
<br>
</body>
</html>

Mime
View raw message