-->
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: Hibernate-SlowQuery
PostPosted: Mon May 30, 2011 8:19 am 
Newbie

Joined: Sat Dec 11, 2010 8:49 am
Posts: 19
Hello,

I am using Hibernate Criteria for retrieving data from database.
I am using paging to show results (cause ClassA has ~13000 rows) so my method looks like:

Criteria criteria = session.createCriteria(
ClassA.class.getName()).setFirstResult(offset * maxResults).setMaxResults(maxResults);
ClassA has one many-to-many and one one-to-many relation.

I noticed that query is fast when database is on the same computer as application.
But when i connect to remote database, it takes around minut to see first page (600 rows).
However when i retrieve another 600 rows (from 600 to 1200) it is retrieved in couple seconds.
Only first query is very slow.
I tried to set fetch mode to JOIN and fetch type to EAGER for all associations but query is still very slow.
I examined log file and i can see that hibernate is calling same query many times.

Can someone help me about this issue, what i am doing wrong?

I created similar query in MySQL browser and get results in few seconds.

Best regards.


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.