-->
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: UNION concept, multi-boolean queries
PostPosted: Tue Apr 07, 2009 9:17 am 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
General question from the HQL/JPA-QL perspective --

If you write a JPA-QL query such as the following with multi-boolean where clause (note, this is an example for simplicity to show boolean query, not to be used to 'solve' the problem with hibernate search):

SELECT o from MyObject o WHERE (o.firstname = 'jon' OR o.firstname='john') AND (o.lastname = 'smith' OR o.lastname='smithe')

With the above query, the few DBMS's I've tried do NOT use indexes correctly related to the number of OR's in the WHERE clause.

However, if re-written such as SQL:

Select * from MyObject WHERE o.firstname = 'jon' AND o.lastname='smith'
UNION
Select * from MyObject WHERE o.firstname = 'john' AND o.lastname='smithe'
UNION
Select * from MyObject WHERE o.firstname = 'jon' AND o.lastname='smith'
UNION
Select * from MyObject WHERE o.firstname = 'john' AND o.lastname='smithe'

The underlying DBMS now uses indexes appropriately. I know this is an unusual use-case, but looking for feedback on the forums about feasibility/drawbacks to putting a HINT to create the assoicated SQL from the HQL/JPA-QL query to be 'unionized'. Do not want to create a ticket without initial discussion.

thanks,
-D


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.