-->
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.  [ 1 post ] 
Author Message
 Post subject: OneToManyPersister performance Optimization
PostPosted: Tue Jun 10, 2014 9:04 am 
Newbie

Joined: Tue Jun 10, 2014 8:42 am
Posts: 1
I am using hibernate 4.2.12.FINAL

I found that the OneToManyPersister is often doing an unnecessary count query which can have a large negative affect on performance in some circumstances and is easily fixed.

The method doProcessQueuedOps is performing a count query any time an addition or deletion occurs in the collection. But it is only necessary when:
Code:
isInverse && hasIndex && !indexContainsFormula
This can cause contention when many threads are writing new objects to the associated table.

To fix this the writeIndex method could be wrapped in an if statement.

Code:
protected void doProcessQueuedOps(PersistentCollection collection, Serializable id, SessionImplementor session)
         throws HibernateException {
                if ( isInverse && hasIndex && !indexContainsFormula ) {
                         writeIndex( collection, collection.queuedAdditionIterator(), id, getSize( id, session ), session );
                }
   }


I am not sure if this issue affects newer versions of hibernate but it still happens in 4.2.13.final.


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

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.