-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Side-effects of large batch-size (say 100).
PostPosted: Wed Nov 23, 2005 7:38 pm 
Newbie

Joined: Wed Nov 23, 2005 6:25 pm
Posts: 10
Location: Austin, Texas
Hi all,

Any reason why setting a large batch-size, say batch-size = 100, is particularly bad?

Everything I've read about batch-size on Entities or collections say to keep this number small, preferably under 10.

I have a worst-case scenario that returns hundreds (possibly 2 or 3 thousand) of Items. The average case is most likely under a hundred.

As you can see from the sample mappings below, each Item has two collections that are not lazy loaded. This results in an additional 2 queries per Item returned.

If there are M Items to return, and the batch-size is set to N on both collections, the number of queries is roughly 2*M/N. My current configuration confirms this.

What are the side-effects of specifying a large batch-size?? E.g. I'd like to set the batch-size = 100, so for our large users this would result in only a dozen queries at most. Any reason why this would be bad, besides memory considerations?

My gut tells me that this is a bad thing, but I can't think of a concrete reason (except for memory considerations and large generated SQL), why this would be bad.

Even if batch-size = 1, the heap still has to handle 2 thousand items.

The only other thing is that the generated SQL underneath could potentially be very big with all the added (alias0.id=?) OR (alias0.id=?) OR ....

Thanks!

Hibernate version: Hibernate 2.1.7

Mapping documents:
These are sample mappings.
Code:
<class name="Item" table="items" discriminator-value="4" polymorphism="explicit">
  <id name="id" column="id" access="field" unsaved-value="-2147483648">
    <generator class="identity"/>
  </id>
  <discriminator column="discriminator" type="integer"/>
  <property name="userName"/>
  <set name="dogs" table="mapItemToDogs"
       cascade="none" access="field" batch-size="10">
    <key column="itemID"/>
    <many-to-many class="Dog" column="dogId"/>
  </set>
  <set name="cats"
       cascade="all-delete-orphan" access="field" batch-size="10">
    <key column="itemID"/>
    <one-to-many class="Cat"/>
  </set>
</class>


Sample HQL query:
Code:
from Item i where i.userName = :userName


Database: SQLServer 2000


Top
 Profile  
 
 Post subject: PING'ed topic
PostPosted: Mon Nov 28, 2005 6:12 pm 
Newbie

Joined: Wed Nov 23, 2005 6:25 pm
Posts: 10
Location: Austin, Texas
Reposted Topic, hopefully to get more views and responses.

http://forum.hibernate.org/viewtopic.php?t=950655


Top
 Profile  
 
 Post subject: Re: PING'ed topic
PostPosted: Mon Nov 28, 2005 6:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
MustangCoder wrote:
Reposted Topic, hopefully to get more views and responses.

http://forum.hibernate.org/viewtopic.php?t=950655


Do not do this kind of thing again.


Top
 Profile  
 
 Post subject: Re: PING'ed topic
PostPosted: Mon Nov 28, 2005 6:35 pm 
Newbie

Joined: Wed Nov 23, 2005 6:25 pm
Posts: 10
Location: Austin, Texas
gavin wrote:
Do not do this kind of thing again.


Sorry. :-(

Thanks for the quick response!!
I will not do this kind of thing again.
:-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.