-->
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: Session.get is too slow
PostPosted: Sat Feb 27, 2010 5:28 am 
Newbie

Joined: Sat Feb 27, 2010 4:57 am
Posts: 2
Hi All!

I am using the Hibernate 3.2.6GA with Java 6 and I am expiriencing the performance problems by calling Hibernate session.get(class Class, id Serializable) method. I am using EhCache (1.6.0), and I am trying to retrieve already cached objects using session.get method. Here is the piece of test code:

Code:
  private void testCache() {
    Session currentSession = HibernateUtil.getCurrentSession();
    //read all keys from DB for testing
    List list = currentSession.createSQLQuery("select employee_key from employee")
      .addScalar("employee_key", Hibernate.LONG ).list();
    //retrieve objects from cache
    for(Object elem : list){
      currentSession.get(DBEmployee.class, (Serializable)elem);
    }
    System.out.println("ready");
  }


The DBEmployee entity has a cache. I do not see any SQL statements from Hibernate during this method run, since all objects are precached already. There are about 30.000 employee objects. Profiling this method I get the following picture:
Image

Whole test method run takes about 27 seconds, whereas the fireLoad takes about 2 seconds only. Why it is needed to spent another 25 seconds for some 'afterTransactionCompletion' call, if I even haven't started any transaction there?

Thank you for your answers!


Last edited by alex.koop on Mon Mar 01, 2010 10:12 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Session.get is too slow
PostPosted: Mon Mar 01, 2010 3:35 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Why it is needed to spent another 25 seconds ...


I suggest you to issue several
Code:
jstack <jvm_pid>

commands during this 25 second.

Analyzing the stacktraces will help you to understand where's the bottleneck.
(did you already recognize it in afterTransactionCompleted ?)
Once you had recognize the bottleneck, debug the concerning code.
Usually this help a lot to understand whats the cause of the bad performance.


Top
 Profile  
 
 Post subject: Re: Session.get is too slow
PostPosted: Mon Mar 01, 2010 10:16 am 
Newbie

Joined: Sat Feb 27, 2010 4:57 am
Posts: 2
The same thing here: http://opensource.atlassian.com/project ... e/HHH-1311


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.