-->
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: the query cost too much time
PostPosted: Tue May 21, 2013 2:41 am 
Newbie

Joined: Tue May 21, 2013 2:28 am
Posts: 2
String hql = "from A a, B b where a.id = b.id and a.value in(:values)";
Query query = session.createQuery(hql);
query.setParameterList("values", {1,2,3});
List list = query.list();

table A contains 10,000+ records, table B contains 30,000 records;
id is the pk of A, and B has a pk(id + name)
the query result contains about 20,000+ records
but the query cost 6 to 10 mins

how should i reduce the query time


Top
 Profile  
 
 Post subject: Re: the query cost too much time
PostPosted: Tue May 21, 2013 6:40 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
Analyze what your DB is doing with that statement and create some useful indexes.


Top
 Profile  
 
 Post subject: Re: the query cost too much time
PostPosted: Wed May 22, 2013 9:31 pm 
Newbie

Joined: Tue May 21, 2013 2:28 am
Posts: 2
CDillinger wrote:
Analyze what your DB is doing with that statement and create some useful indexes.


thanks for your reply.
a.id is the primary key. and I created a index on a.value and b.id each other.
but that does not make any change.

then i used jdbc to do the query. and it just cost 2 to 3 seconds.
this is the jdbc sql : "select a.id, a.value, b.id from a, b where a.id = b.id and a.value = ?";

I want to know what makes such a big difference.
and how should i reduce the hibernate query time.


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.