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.  [ 6 posts ] 
Author Message
 Post subject: Performance issue: collections containing collections
PostPosted: Tue May 10, 2005 9:02 am 
Newbie

Joined: Wed Jan 05, 2005 6:54 am
Posts: 15
Hi,

I recently stumbled over a performance issue that I want to describe first in a simple example.

Imagine the following configuration:

Code:

<class name="sample.Entity" table="ENTITY">

   <id name="id" type="long">
      <column name="ENTITY_ID" not-null="true" />
      <generator class="native" />
   </id>

   <set name="attributes" table="ENTITY_PROPERTY" lazy="false" cascade="all-delete-orphan">
      <key column="ENTITY_ID" />
      <many-to-many class="sample.Property" column="PROPERTY_ID" />
   </set>

[...]

</class>

<class name="sample.Property" table="PROPERTY">

   <id name="id" type="long">
      <column name="PROPERTY_ID" not-null="true" />
      <generator class="native" />
   </id>

[...]

</class>



I am querying now a list of all of those entities:
Code:
select e from Entity
.

Every loaded entity can have a flexible amount of properties. Now I want to display every single property of every single entity. But this is expensive, because Hibernate now will first select all entities and then, for every single entity, select the properties joining them to the current entity.
For a hundred of entities, a hundred join-selects are executed.

Now that Hibernate knows that I do not want to lazy-load the Properties it could as well fetch the PROPERTY-TABLE in one statement. I believe this would increase the performance significantly. Would it?
A developer then could decide between loading lazily (only if needed) or performantly (if the collection is initialized anyway).

What do You think?

Regards,

Pvblivs


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 9:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Read the documentation about subselect fetching.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 9:18 am 
Newbie

Joined: Wed Jan 05, 2005 6:54 am
Posts: 15
Thanks a lot, gavin!

I hoped hibernate could do it.

The only difficulty now is to migrate with jboss to h3. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 12, 2005 5:44 pm 
Beginner
Beginner

Joined: Thu May 20, 2004 3:40 pm
Posts: 33
Hello!!

Where is the documentation on subselect fetching??

I only found the following in the H3 Docs:

20.1.6. Using subselect fetching
TODO

Thanks!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 4:58 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Dig into the unit test suite for now.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 5:55 am 
Beginner
Beginner

Joined: Thu May 20, 2004 3:40 pm
Posts: 33
Got it!! Thanks Again!!!

Kenny


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.