ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Batch question.
Date Thu, 27 Jul 2006 14:32:21 GMT
A batch may help you if you can group identical statements together in your
transaction.  iBATIS calculates "sub batches" based on the generated SQL -
but you cannot mix the statements at will.  If a new statement is added to a
batch that does not match the immediately preceding statement, then a new
sub batch is created.  For example, this is 4 sub-batches and should yield a
performance improvement:

insert into table1...
insert into table1...
insert into table1...
update table1...
update table1...
update table1...
insert into table1...
 insert into table1... insert into table1...
 update table1...
update table1...
update table1...

But the following will turn into 12 sub-batches - no performance
improvement:

insert into table1...
update table1...
insert into table1...
update table1...
insert into table1...
update table1...
insert into table1...
update table1...
insert into table1...
update table1...
insert into table1...
update table1...

Some JDBC drivers cache prepared statements and in those cases the
differences won't be so significant.  As always with any performance
discussion, your milage may vary.

Jeff Butler



On 7/27/06, Albert L. Sapp <asapp@uiuc.edu> wrote:
>
> Hi, everyone.
>
> Did not know whether this fit in with recent question on iBatis batch
> support :-) , so I just sent a separate email.
>
> Is there any rule-of-thumb for determining when to use batch within a
> transaction?  I have a shopping cart application and, when the user goes
> through checkout, there are a number of inserts, updates and deletes for
> each item in the cart that are performed.  Right now, I just put them
> all between start, commit and end transaction tags.  It works fine this
> way with rollback happening cleanly, when needed.  I don't think there
> will ever be a large number of items at any one time to in a user's
> shopping cart, but was wondering if it is still a "best practice" to put
> inside batch tags as well.
>
> Always try to keep up on "best practices".  ;-)
>
> Thanks,
>
> Al
>
>

Mime
View raw message