-->
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: HQL filter elements() bad performance
PostPosted: Wed Sep 19, 2012 3:21 am 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
Hi there,

I have a HQL something like this:

Code:
from MyDocument md where :keyword in elements(md.keywords)


It give me the required results, but the performance is slow when there are thousand of MyDocument entries. Even when none of them has any keywords!

Can I rewrite the query to speed up it? The only way I have archived good performance is with native SQL, but I try to avoid it if possible.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: HQL filter elements() bad performance
PostPosted: Mon Sep 24, 2012 10:07 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Can I rewrite the query to speed up it?


The book "Java Persistence with Hibernate" (see above at the top of the page) writes following:
Quote:
... you should question frequent use of subqueries because queries with subqueries can often be rewritten using only joins and aggregation.


Top
 Profile  
 
 Post subject: Re: HQL filter elements() bad performance
PostPosted: Mon Sep 24, 2012 11:18 am 
Newbie

Joined: Sat Feb 12, 2011 3:49 pm
Posts: 13
Ok, I see this phrase in page 662, I will take a look into the chapter.


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.