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:

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...