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: Very slow query using LIKE with hibernate but fast direct
PostPosted: Thu Apr 08, 2010 9:15 am 
Newbie

Joined: Thu Apr 01, 2010 6:36 am
Posts: 7
Hi,
I've got a strange behaviour. I've got a very simple select statement

SELECT d.someVal from PoDetails d where d.val LIKE 'SOMETHING'

If I execute this against a very large Progress db table it takes about 65 seconds using Hibernate (tested with the HQL Editor in Eclipse) while the same query takes about 1-3 seconds with SquirreL (not due to caching, i've changed the search string to test that).

If I replace the LIKE with = the request time is only about 3 seconds with Hibernate. I know that LIKE is more expensive and that it doesn't make sense without % (my original query used 'BLA%') but it shouldn't be 65 seconds vs 3 seconds if the difference with SquirreL is hardly noticeable.

I tried to debug this using a packet sniffer but somehow no results are returned while the sniffer is active.

Any ideas what could be the problem?

Regards

Immo


Top
 Profile  
 
 Post subject: Re: Very slow query using LIKE with hibernate but fast direct
PostPosted: Thu Apr 08, 2010 3:39 pm 
Newbie

Joined: Thu Apr 08, 2010 11:34 am
Posts: 7
You may want to try to log the statements sent to the database.

If Hibernate does not have any specific setting to turn logging on, you may do so by using an interceptor.

public class StatementInterceptor extends EmptyInterceptor {
private static Logger logger = LogManager.getLogger(StatementInterceptor.class)


public String onPrepareStatement(String sql) {
logger.debug(sql);
}

}


Top
 Profile  
 
 Post subject: Re: Very slow query using LIKE with hibernate but fast direct
PostPosted: Fri Apr 09, 2010 5:56 am 
Newbie

Joined: Thu Apr 01, 2010 6:36 am
Posts: 7
The HQL editor lets you see the generated SQL statement before you post it (quite nice for fine tuning your requests)
and I used the generated SQL in SquirreL.


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.