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.  [ 2 posts ] 
Author Message
 Post subject: huge perfomance degradation
PostPosted: Thu May 13, 2010 10:54 am 
Newbie

Joined: Mon Mar 22, 2010 9:42 am
Posts: 2
Hello,

I'm running a simple list in a table of about 150.000 records. I'm using a pagination to get the records 1000 per 1000, the first query is pretty fast, but I issue a HUGE performance degradation, the query execution time increase, increase...

First execution takes about 100ms, 10th execution 475ms... the 100th execution is taking already 4,5 secondes and it is still growing, the last execution needs 8 secondes to be done.

Here are the interesting part of my code:

. The query itself:

Code:
Criteria crit = getSession().createCriteria(MyClass.class);
for(int i=0 ; true ; i++) {
         List list = crit.add(Restrictions.in("status", ConstantsUtil.Indexable.STATUS))
               .setFirstResult(i*MAX_LIST_SIZE).setMaxResults((MAX_LIST_SIZE)).list();

         if(list.size() == 0 || list == null)   break;
         //task I do (problem still occurs when it's commented)         
      }



And I also made some profiling, here is a screenshot of the problematic part:
Image

as you can see, the "flush system" is called a crazy number of times, and takes about 70% of the execution time.


I already tried to disable the cache (CacheMode.IGNORE), to change the flush mode (FlushMode.COMMIT), but as soon as I use list(), something goes wrong.

Actually, I noticed that if I use ScrollableResult instead of list(), the problem is solved, but I would like to be able to use list() in my application...


Top
 Profile  
 
 Post subject: Re: huge perfomance degradation
PostPosted: Mon May 17, 2010 11:40 am 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
For the firstResult, try using addition instead of multiplication. Create another variable for that and do a firstResult += maxResult.


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