Account Options

  1. Sign in
Google Groups Home
« Groups Home
$or index use
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Scott Hernandez  
View profile  
 More options Aug 5 2010, 5:44 pm
From: Scott Hernandez <scotthernan...@gmail.com>
Date: Thu, 5 Aug 2010 14:44:34 -0700
Local: Thurs, Aug 5 2010 5:44 pm
Subject: $or index use
What is expected index use for queries with $or; should we consider
them to be broken up as a combination of queries for each $or clause
where the index for that clause will be used and then duplicates
removed?

sample doc: {_id:1, a:1, b:2, c:3}

find({a:1, $or: [{b:2, c:3}]}) -> find({a:1, b:2}) + find({a:1, c:3}) = results?

How does this change when sorting?

Also, it would be good to update the docs with this info:

http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-...
http://www.mongodb.org/display/DOCS/OR+operations+in+query+expressions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aaron  
View profile  
 More options Aug 5 2010, 9:32 pm
From: aaron <aa...@10gen.com>
Date: Thu, 5 Aug 2010 18:32:50 -0700 (PDT)
Local: Thurs, Aug 5 2010 9:32 pm
Subject: Re: $or index use

On Aug 5, 2:44 pm, Scott Hernandez <scotthernan...@gmail.com> wrote:

> What is expected index use for queries with $or; should we consider
> them to be broken up as a combination of queries for each $or clause
> where the index for that clause will be used and then duplicates
> removed?

> sample doc: {_id:1, a:1, b:2, c:3}

> find({a:1, $or: [{b:2, c:3}]}) -> find({a:1, b:2}) + find({a:1, c:3}) = results?

Yeah, to get good worst case performance we do the clauses one at a
time.  While evaluating clauses we check whether a given document
would have been returned as part of the scan for an earlier clause and
we shouldn't return it if so.  There are some cases where we can avoid
looking at certain index ranges in later clauses because they have
already been explored in earlier clauses.  We are going to increase
the scope of these optimizations for 1.8 - SERVER-1213

Also, I should mention that while you are doing the initial query the
full query optimizer is employed to choose the best index for each
clause.  But once you start doing get mores, the index selection is
more primitive.  This was requested behavior for 1.6, but we are going
to enhance for 1.8 - SERVER-1215.

> How does this change when sorting?

Right now if you have a sort spec the $or is completely ignored from
the perspective of indexing.  This is another feature that was
designated for 1.8 and there is a bug for it SERVER-1205.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »