-->
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.  [ 5 posts ] 
Author Message
 Post subject: Deeply nested object models (performance)
PostPosted: Thu Dec 29, 2005 6:51 pm 
Newbie

Joined: Mon Jun 27, 2005 11:33 am
Posts: 8
I'm having a general performance tuning problem and I'm wondering if any of you have had a similar experience. We have a deeply nested object model, 4 or 5 levels deep in some places, with several objects having 5 or more one-to-many relationships and a handful of many-to-one. The number of queries that it is taking to pull in all the data we need is staggering. We have turned off lazy fetching where appropriate and tried batch-sizes of 10 and 100. We are still struggling for acceptible performance. My guess is that we are simply dealing with too many one-to-many relationships. Is Hibernate really limited to eager fetching only one of these per query?

If you have such a use case, could you please share some tips? Are there other strategies that we should be exploring, like a stored procedure or view combined with a flattened object?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 7:00 pm 
Newbie

Joined: Mon Jun 27, 2005 11:33 am
Posts: 8
I should also point out that most of the one-to-many relationships are more like one-to-a-few. It is more a problem of how many of these relationships there are at each level (thus driving up the number of queries).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 7:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, Hibernate does not any longer have this limitation.

So you can use multiple outer join fetches.

Or you can try subselect fetching.


(Batch fetching is not a good way to solve this problem, as you can see.)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 7:08 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Analyze your model for relationships which should (nearly) always be eagerly loaded, and use the fetch="join" strategy for them. Stick with select fetching for relationships which are only rarely used.

Ensure that your cache is configured correctly.

Consider providing multiple load methods in your access layer; some will use the default (mostly lazy) loading, and some will eagerly fetch the relevant data (using Hibernate.initialize). You must have some context information that you can use to tune your mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 9:29 pm 
Newbie

Joined: Mon Jun 27, 2005 11:33 am
Posts: 8
gavin wrote:
No, Hibernate does not any longer have this limitation.


Just wondering, in what version was this added? I tried it before and could not get it to work. Or is there still a limitation in HQL to only one one-to-many fetch?


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