-->
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.  [ 3 posts ] 
Author Message
 Post subject: HIbernate in production under heavy load
PostPosted: Wed Aug 17, 2011 8:08 am 
Newbie

Joined: Tue Jun 07, 2011 1:02 pm
Posts: 7
can anybody share the hibernate performance in production for a very large dataset and performing queries on multiple tables (say 10) for eager fetching and resulting in hunderds/thousands of records? And what is the opinion about the hibernate performance for such projects?


Top
 Profile  
 
 Post subject: Re: HIbernate in production under heavy load
PostPosted: Wed Aug 17, 2011 5:26 pm 
Beginner
Beginner

Joined: Thu Oct 08, 2009 11:44 am
Posts: 21
Location: Chicago
I have a similar situation and have found that I had very bad performance and had to re-engineer the queries around that. I am sure some sophisticated tuning is in order. The simple model of the connected network of objects in memory can have a lot of overhead. Lazy fetching is important. I found I resorted to some native SQL to get lists of the transaction numbers I needed and loop through that list to do fetches of an object network. I was getting timeouts trying to do the simple thing.


Top
 Profile  
 
 Post subject: Re: HIbernate in production under heavy load
PostPosted: Thu Aug 18, 2011 2:25 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
In our experience the limitation is the performance of the database. But there are some situations that have hit us in the past.

N+1 select problem: We had a non-lazy entity referenced from a many-to-one association. This caused lots of additional selects against the database as we iterated the result set from a query. We didn't need the data so the solution was making the entity lazy. This was a long time ago when the default setting was lazy=false. Since that has changed to lazy=true it is not likely to happen anymore. On the other hand, if the associated data is needed it will not help to use lazy fetching. Then your query should fetch join the association to bring in all data in a single query.

Auto flush mode: Beware of the AUTO flush mode when you handle a lot of entities in a session. If Hibernate decides that flush is needed it will dirty-check all entities which may take a long time. We were importing data from text files. It was a single table, one entry on each line and just a few properties. However, we needed to check if a new row should be inserted or if an existing one should be updated. The query to do this check triggered a flush+dirty-check in Hibernate. As the session filled up with entities each iteration took more an more time. After about 10000 rows it was really slow. There are two solutions.

  • Do not use AUTO flush mode.
  • Evict entities from the session as soon as they are no longer needed.

As far as I remember the two things above are the only Hibernate-related performance issues we have had. But they could be solved and if anything else pops up I am sure that it can be solved as well.


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