-->
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: Criteria queries and database indices
PostPosted: Sun May 14, 2006 12:16 pm 
Newbie

Joined: Fri Sep 02, 2005 3:51 pm
Posts: 17
Hi,
I am using hibernate to query a database of orders. The result set returned is generally in the thousands. We have created indices on the database for the searches.

The problem is that while using the crtieria class, expressions or restrictions get added in a certain order. If a certain criteria is not applicable, we would have to skip it (say for example if admin is doing a search, we do not need to set the customerId, but if customer is searching then only that customer's orders are to be returned, hence id needs to be set).
If a certain criteria is not added, the chain of the indices is broken and from what I understand, that composite index will not kick in for the query.

For examle, if search is perfomed in the following order...

customerId, dateCreated, status, amount

then we create a coposite index in that order. Now say if status is not defined (get orders of all status), then our query would be based on customerId, dateCreated and amount, which brreaks teh index chain.

My question is, what is the best approach to handle such an issue. Please keep in mind that our query criteria contain many more properties than the 4 mentioned above.

Thanks,
-Riz.


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.