-->
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.  [ 6 posts ] 
Author Message
 Post subject: Slow queries with postgres
PostPosted: Thu Nov 17, 2005 2:20 pm 
Newbie

Joined: Thu Nov 17, 2005 2:05 pm
Posts: 3
Postgres has a problem with using an index in some cases, and I think it is causing a collection to be loaded slowly in one of my hibernate objects. The problem is described in the user comments at the bottom of the page here:
http://www.postgresql.org/docs/7.4/interactive/indexes.html

Has anyone else experienced a problem with this, and is there a workaround or fix? I'm currently using Hibernate 3.0.5 and also tried the most recent release candidate.


Top
 Profile  
 
 Post subject: Re: Slow queries with postgres
PostPosted: Thu Nov 17, 2005 2:48 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
jsun wrote:
Postgres has a problem with using an index in some cases, and I think it is causing a collection to be loaded slowly in one of my hibernate objects. The problem is described in the user comments at the bottom of the page here:
http://www.postgresql.org/docs/7.4/interactive/indexes.html

Has anyone else experienced a problem with this, and is there a workaround or fix? I'm currently using Hibernate 3.0.5 and also tried the most recent release candidate.

Yes, there are many way to tune PostgreSQL. Have you tried to view query plan (generated query with EXPLAIN prefix) ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 3:10 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
Is your performance issue only applied for the collection HQLs? Or is it a general issue?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 3:15 pm 
Newbie

Joined: Thu Nov 17, 2005 2:05 pm
Posts: 3
If I manually type a query into psql it is as would be expected as described in the 'User Comments' section of the page

So something like
SELECT record WHERE record.an_id=11111
returns a query plan that doesn't use the index on 'an_id', whereas:
SELECT record WHERE record.an_id='11111'
returns a query that does use an index

The hibernate object I am having problems with has a collection that would generate a query something like those queries and is taking about 10 seconds. The query time for the slow version when I type it into psql is also around 10 seconds and the fast version is a fraction of a second. I don't believe it is a tuning problem, but rather a bug with postgres. What I'm wondering is if there is a workaround to get hibernate to query in the way that will use the faster version. Or perhaps hibernate has no control over it and that would be handled in the jdbc driver. I'm not sure.

Thanks,
Jason


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 3:19 pm 
Newbie

Joined: Thu Nov 17, 2005 2:05 pm
Posts: 3
The problem is only showing up in one particular collection, but that collections records come from a table that has over 500,000 records. So it might be that is the only place that it is noticable, since most of the other tables are smaller.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 4:46 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It looks like you are using "old" driver. If this is a "new" driver then wrapp it and implement PreparedStatement.setLong() this way :

void setLong(int index,long value){

delegate.setString(index,Long.toString(value));

}


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