<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:56:22 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-1205] $or sort does not use index ranges expressed in or clauses</title>
                <link>https://jira.mongodb.org/browse/SERVER-1205</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Decide whether or not this is necessary and if it is then implement.&lt;/p&gt;</description>
                <environment></environment>
        <key id="12097">SERVER-1205</key>
            <summary>$or sort does not use index ranges expressed in or clauses</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="hari.khalsa@10gen.com">hari.khalsa@10gen.com</assignee>
                                    <reporter username="aaron">Aaron Staple</reporter>
                        <labels>
                            <label>query_triage</label>
                    </labels>
                <created>Tue, 8 Jun 2010 23:08:51 +0000</created>
                <updated>Fri, 7 Apr 2023 15:31:00 +0000</updated>
                            <resolved>Fri, 10 Jan 2014 20:10:16 +0000</resolved>
                                                    <fixVersion>2.5.5</fixVersion>
                                    <component>Querying</component>
                                        <votes>115</votes>
                                    <watches>107</watches>
                                                                                                                <comments>
                            <comment id="564349" author="xres74" created="Sun, 27 Apr 2014 05:36:59 +0000"  >&lt;p&gt;I have created an issue with explaining the above: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-13754&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-13754&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="564342" author="asya" created="Sun, 27 Apr 2014 05:22:33 +0000"  >&lt;p&gt;Edouard:  please include data, query and explain with these kinds of reports otherwise it&apos;s very difficult to validate what works like it&apos;s supposed to and what doesn&apos;t.&lt;/p&gt;</comment>
                            <comment id="564322" author="xres74" created="Sun, 27 Apr 2014 04:31:05 +0000"  >&lt;p&gt;It seems that at current version (2.6.1), the query optimizer is still unable to optimize queries that use $or, $in, limit() and sort() all at once. The &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1205&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-1205&lt;/a&gt; and &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-3310&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-3310&lt;/a&gt; fixes, each only improved performance on queries having 3 out of the 4 operations listed above. When introducing a 4th operation into the query, the optimization goes out the window. This behavior is observed with full index and document scans within the $or clause, even though a limit() is specified.&lt;/p&gt;</comment>
                            <comment id="553463" author="xgen-internal-githook" created="Thu, 17 Apr 2014 18:38:23 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;dstorch&apos;, u&apos;name&apos;: u&apos;David Storch&apos;, u&apos;email&apos;: u&apos;david.storch@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1205&quot; title=&quot;$or sort does not use index ranges expressed in or clauses&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1205&quot;&gt;&lt;del&gt;SERVER-1205&lt;/del&gt;&lt;/a&gt; add test for explode for sort with meta sort spec&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/5c486649ce4f237db01942e48ea8683489bac8ca&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/5c486649ce4f237db01942e48ea8683489bac8ca&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="499239" author="kof" created="Fri, 14 Feb 2014 12:29:03 +0000"  >&lt;p&gt;Hopefully this will be released soon, as it is a blocker issue for me too:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/mongodb-user/Vbmp3_dtarY&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://groups.google.com/forum/#!topic/mongodb-user/Vbmp3_dtarY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks to Andrew Ryder who has explained this.&lt;/p&gt;</comment>
                            <comment id="480398" author="xgen-internal-githook" created="Fri, 10 Jan 2014 20:06:27 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hkhalsa&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1205&quot; title=&quot;$or sort does not use index ranges expressed in or clauses&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1205&quot;&gt;&lt;del&gt;SERVER-1205&lt;/del&gt;&lt;/a&gt; explode point interval scans to obtain sort&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/9cfca59caf6426bf3c14fa3730aa58003b223386&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/9cfca59caf6426bf3c14fa3730aa58003b223386&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="476112" author="skmasq" created="Tue, 31 Dec 2013 17:48:16 +0000"  >&lt;p&gt;+1 This issue is causing lot of workarounds to our solution.&lt;/p&gt;</comment>
                            <comment id="454120" author="oran@win.com" created="Sun, 10 Nov 2013 13:33:07 +0000"  >&lt;p&gt;+1, critical for the entire developer team in my company.&lt;/p&gt;</comment>
                            <comment id="454118" author="klimashkin" created="Sun, 10 Nov 2013 13:13:26 +0000"  >&lt;p&gt;+1, Faced with the same problem. Very critical &lt;br/&gt;
Really can wait in 2.5.4?&lt;/p&gt;</comment>
                            <comment id="435658" author="subramanyahs" created="Fri, 4 Oct 2013 09:29:36 +0000"  >&lt;p&gt;+1, we are facing lot of challenges with this bug &lt;/p&gt;</comment>
                            <comment id="435657" author="srini_ramamurthy@bmc.com" created="Fri, 4 Oct 2013 09:25:42 +0000"  >&lt;p&gt;+1&lt;br/&gt;
if someone using mongoose (see: mongoose-when)&lt;br/&gt;
currently we use promises with multiple queries which asynchronously executes and wait for all to finish and apply some application logic for post processing.&lt;/p&gt;</comment>
                            <comment id="411501" author="jonathan.gaillard@dominionenterprises.com" created="Mon, 26 Aug 2013 15:55:15 +0000"  >&lt;p&gt;+1 for this need as we make heavy use of these queries ! &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/biggrin.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="384661" author="auto" created="Fri, 19 Jul 2013 13:27:19 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hkhalsa&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-10026&quot; title=&quot;New query system&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-10026&quot;&gt;&lt;del&gt;SERVER-10026&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-10192&quot; title=&quot;Add sorting&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-10192&quot;&gt;&lt;del&gt;SERVER-10192&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1205&quot; title=&quot;$or sort does not use index ranges expressed in or clauses&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1205&quot;&gt;&lt;del&gt;SERVER-1205&lt;/del&gt;&lt;/a&gt; sorting stages&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/cc54cdf3aa4a42308d135a393bf736aeb58d89d1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/cc54cdf3aa4a42308d135a393bf736aeb58d89d1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="330819" author="eliot" created="Wed, 8 May 2013 05:43:38 +0000"  >&lt;p&gt;The current fixVersion is 2.5.w (see above), meaning we&apos;re trying to get it into 2.6.&lt;br/&gt;
We&apos;re doing a lot of work on the query optimizer to make things of this nature easier.&lt;br/&gt;
Once that is done, this, and many related tickets will get resolved.&lt;/p&gt;</comment>
                            <comment id="330011" author="gotys" created="Tue, 7 May 2013 07:57:29 +0000"  >&lt;p&gt;Common guys ! It&apos;s been 2 years since this issue was opened ! What is the current state on this ? Are you really going to fix this or not ?&lt;/p&gt;</comment>
                            <comment id="323298" author="stevemcmillen" created="Sun, 28 Apr 2013 02:55:50 +0000"  >&lt;p&gt;This bug will cost our organization a deal of time to develop around this deficiency.  Can someone at 10gen please indicate if this is going to be resolved and when so we all don&apos;t have to keep guessing at if we should spend the effort to work around this problem or wait?&lt;/p&gt;</comment>
                            <comment id="307989" author="jhn" created="Sun, 7 Apr 2013 16:19:54 +0000"  >&lt;p&gt;Fully agree with the comments above. One vote from me as well and hoping to see this in 2.6.&lt;/p&gt;</comment>
                            <comment id="300564" author="nana" created="Thu, 28 Mar 2013 08:12:34 +0000"  >&lt;p&gt;Really big issue for us... +1 for a fix.&lt;/p&gt;</comment>
                            <comment id="290033" author="mamoos1" created="Fri, 15 Mar 2013 12:44:13 +0000"  >&lt;p&gt;Really big issue for us... +1 for a fix.&lt;/p&gt;</comment>
                            <comment id="275693" author="nlyn" created="Mon, 25 Feb 2013 23:07:42 +0000"  >&lt;p&gt;We&apos;re in the process of switching back to RDBMS for our activity stream because of this. Quite disappointed as Mongo is the perfect tool in every other area for us.&lt;/p&gt;</comment>
                            <comment id="275685" author="adro75" created="Mon, 25 Feb 2013 22:56:50 +0000"  >&lt;p&gt;So, which is more efficient, using the indices combined from the &quot;or&quot; or the index from the &quot;sort&quot;? Agreed, this is a major weakness compared to SQL DB&apos;s!&lt;/p&gt;</comment>
                            <comment id="269208" author="janson1983@gmail.com" created="Mon, 18 Feb 2013 13:17:14 +0000"  >&lt;p&gt;This bug has very long time.I need use or and sort query together in my job. I want you can  solve it as soon as possible. Thanks!&lt;/p&gt;</comment>
                            <comment id="253351" author="dan@10gen.com" created="Wed, 30 Jan 2013 01:09:26 +0000"  >&lt;p&gt;10gen definitely considers this a priority and a fix is currently scheduled as one of the top priorities for the 2.6 release.  We are currently making major refactor to the query planner (matcher) and optimizer which will include a fix for this issue.  However, it was not easy to make this fix with the current architecture in advance of the fundamental code changes that are currently underway.&lt;/p&gt;

&lt;p&gt;-Dan&lt;/p&gt;</comment>
                            <comment id="253256" author="carlos8f" created="Tue, 29 Jan 2013 22:43:31 +0000"  >&lt;p&gt;Bugs like this have caused me to abandon MongoDB. I consider it a &quot;legacy&quot; part of my production infrastructure now.&lt;/p&gt;

&lt;p&gt;How many years does a &quot;Major&quot; issue have to be open before 10gen gives a #*!&amp;amp;?&lt;/p&gt;</comment>
                            <comment id="253212" author="gibbonsd1" created="Tue, 29 Jan 2013 21:57:05 +0000"  >&lt;p&gt;+1 for fix. My workaround was to issue 2 separate sorted queries then merge the results in application logic.&lt;/p&gt;</comment>
                            <comment id="253201" author="drapeko" created="Tue, 29 Jan 2013 21:42:59 +0000"  >&lt;p&gt;+1 for a fix. spent significant amount of time trying to understand what&apos;s wrong &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/sad.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="248434" author="nlyn" created="Thu, 24 Jan 2013 09:02:19 +0000"  >&lt;p&gt;+1 for a fix. I first encountered this in summer 2011. The workaround I created then (10 separate queries with a huge limit and then combining the results in PHP) has now been outgrown.&lt;/p&gt;</comment>
                            <comment id="223254" author="andreas@idztech.com" created="Mon, 24 Dec 2012 09:57:09 +0000"  >&lt;p&gt;To bad that this was pushed back, I was really hoping or this in the next release. It would greatly cut down the amount of data I need to send back to the application from MongoDB. Now have to make about 8 queries with limit 20 and then sort and decide which 20 documents to use, instead of just letting MongoDB return the 20 documents.&lt;/p&gt;

&lt;p&gt;I really hope you reconsider and include it in 2.3.x, It&apos;s all I really want for Christmas. =)&lt;/p&gt;</comment>
                            <comment id="202803" author="solowu@cisco.com" created="Fri, 30 Nov 2012 03:03:29 +0000"  >&lt;p&gt;This type of query is used in an important functionality (feed style, sorted by time).&lt;/p&gt;</comment>
                            <comment id="202234" author="isharkov" created="Thu, 29 Nov 2012 15:10:14 +0000"  >&lt;p&gt;+1 to be fixed ASAP&lt;/p&gt;</comment>
                            <comment id="197248" author="ikotev" created="Fri, 23 Nov 2012 11:09:56 +0000"  >&lt;p&gt;Guys,&lt;br/&gt;
Will you able to make it in 2.3.1?&lt;br/&gt;
This is very critical for our activity feed performance optimization where most of the query (and result eliminating) parameters are within an $or clause.&lt;br/&gt;
Without this - the larger the collection is, the worse the performance is. It&apos;s just a matter of time to reach an unacceptable response time when the end user is trying to load its activity feed.&lt;/p&gt;</comment>
                            <comment id="173044" author="hersha" created="Tue, 9 Oct 2012 19:45:10 +0000"  >&lt;p&gt;I agree this needs to be fixed. Before I found this I thought I was just being stupid for a few weeks.&lt;/p&gt;</comment>
                            <comment id="163275" author="ashishtrivedi" created="Wed, 12 Sep 2012 04:52:04 +0000"  >&lt;p&gt;Needs fix very soon. Its preventing very important functionality.&lt;/p&gt;</comment>
                            <comment id="161521" author="tomliugen" created="Fri, 7 Sep 2012 05:59:53 +0000"  >&lt;p&gt;Please fix it ASAP. Thanks!!!&lt;/p&gt;</comment>
                            <comment id="148567" author="elsonwu" created="Mon, 30 Jul 2012 03:28:33 +0000"  >&lt;p&gt;@Montse Medina &lt;br/&gt;
I do agree with you. Please fix it ASAP. Thanks!!!&lt;/p&gt;</comment>
                            <comment id="132400" author="burcu" created="Thu, 14 Jun 2012 07:21:45 +0000"  >&lt;p&gt;Either fix it or document it loudly. At least devs should be aware of the need for an alternative filtering mechanism without querying with $ors.&lt;/p&gt;</comment>
                            <comment id="132284" author="bonna@mail.ustc.edu.cn" created="Thu, 14 Jun 2012 02:26:12 +0000"  >&lt;p&gt;We have the same problem. Will this be fixed in ver2.2 in July?&lt;/p&gt;</comment>
                            <comment id="119733" author="vramanan" created="Tue, 15 May 2012 17:48:35 +0000"  >&lt;p&gt;Badly needing this to be fixed. Without this mongodb looks not so fit for report related applications.&lt;/p&gt;</comment>
                            <comment id="118508" author="x2002g@gmail.com" created="Fri, 11 May 2012 07:28:09 +0000"  >&lt;p&gt;+1 vote. It does not work well even if &quot;hint&quot; an index. Unnecessary index entries and objects are scanned. It should work better.&lt;/p&gt;</comment>
                            <comment id="90752" author="lethum" created="Wed, 22 Feb 2012 08:59:37 +0000"  >&lt;p&gt;+1 for this beeing necessary from me too.&lt;br/&gt;
From my point of view, this is a basic feature i would like to use in my projects.&lt;br/&gt;
The fact that no index is beeing used for or/sort combinations makes it necessary to implement client side sorting.&lt;br/&gt;
Of course this is possible, but I think, the database should be able to do this.&lt;/p&gt;</comment>
                            <comment id="90519" author="vaninwagen" created="Tue, 21 Feb 2012 18:07:59 +0000"  >&lt;p&gt;+1 for this being necessary. &lt;/p&gt;

&lt;p&gt;This is a basic query-use-case we really need.&lt;br/&gt;
Furthermore, with that change made, the behaviour produced by the API would be a bit more predictable.&lt;/p&gt;

&lt;p&gt;Nonetheless, great work! I really enjoy using mongodb (except this issue).&lt;/p&gt;</comment>
                            <comment id="81031" author="aaron" created="Thu, 19 Jan 2012 18:32:30 +0000"  >&lt;p&gt;@arie - The issue here isn&apos;t the choice of indexes, but the fact that we can&apos;t currently sort results returned by a sequence of indexes instead of a single index (which is the way $or works).  Thus even if you could hint a multiple index plan we&apos;d need to sort the results - which is the bulk of the work here.&lt;/p&gt;</comment>
                            <comment id="81022" author="arie@klip.com" created="Thu, 19 Jan 2012 18:08:51 +0000"  >&lt;p&gt;guys, if you are not fixing the optimizer before 2.2 to make the right choice of plans, could you at least expose some mechanism, similar to &quot;hint&quot;, so we can tell the optimizer which plan to use?&lt;/p&gt;</comment>
                            <comment id="69430" author="jberg" created="Tue, 29 Nov 2011 02:09:06 +0000"  >&lt;p&gt;Another vote on this being a pain!  Thanks for all the great work mongo team.&lt;/p&gt;</comment>
                            <comment id="68722" author="aaron" created="Thu, 24 Nov 2011 07:37:44 +0000"  >&lt;p&gt;Michael - the change you have proposed has the effect of dropping the sort spec in some cases.  You may get index usage in these cases, but the results may be ordered incorrectly.  There is a high likelihood this feature will be implemented in 2.2.&lt;/p&gt;</comment>
                            <comment id="68186" author="mbarrien" created="Tue, 22 Nov 2011 11:08:26 +0000"  >&lt;p&gt;This bug prevents us from implementing very basic features of our product, like search pagination because sorting by date absolutely kills performance, and workarounds are all performance killing as well. Because this is so painful, I started looking at the code. In db/queryoptimizer.cpp, line 858 currently looks like this:&lt;/p&gt;

&lt;p&gt;        if ( !order.isEmpty() || !min.isEmpty() || !max.isEmpty() ) {&lt;/p&gt;

&lt;p&gt;Making the following change made it no longer do full table scans for at least some of the cases that affect our work:&lt;/p&gt;

&lt;p&gt;        if ( !min.isEmpty() || !max.isEmpty() ) {&lt;/p&gt;

&lt;p&gt;I&apos;m afraid to make this change by itself, since specifically banning sorts in the code suggests there&apos;s something downstream that assumes sort-order is empty. (i.e. it&apos;s a feature, not a bug).&lt;/p&gt;

&lt;p&gt;Aaron, according to git blame, you&apos;re the only one touching this section of code. Is there any insight you can give into the reason those lines exist, or is it safe to just remove that? (It was last substantially touched in the fix for &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1206&quot; title=&quot;$or hint does not use index ranges expressed in or clauses&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1206&quot;&gt;&lt;del&gt;SERVER-1206&lt;/del&gt;&lt;/a&gt;).&lt;/p&gt;</comment>
                            <comment id="67320" author="montsechka" created="Thu, 17 Nov 2011 03:07:34 +0000"  >&lt;p&gt;This is extremely painful for us. This destroys the our performance. It&apos;s very critical that Mongo fixes this issue as soon as possible, as $or clauses are very frequent in our query load.&lt;br/&gt;
Please, fix in 2.1!&lt;/p&gt;</comment>
                            <comment id="52502" author="swaroop" created="Mon, 5 Sep 2011 20:14:43 +0000"  >&lt;p&gt;We are also facing a lot of problems. I fail to understand why would the sort not use the existing indexes. All sort are resulting in full table scans. Kindly schedule this bug fix on priority.&lt;/p&gt;</comment>
                            <comment id="50756" author="tdemille" created="Thu, 25 Aug 2011 18:36:37 +0000"  >&lt;p&gt;@Carlos  Yes, we are having to devise hacky kind of workarounds as well, and abandon some functionality because of this...&lt;/p&gt;</comment>
                            <comment id="50754" author="carlos8f" created="Thu, 25 Aug 2011 18:31:59 +0000"  >&lt;p&gt;If this is technically feasible to fix, it would be very helpful.&lt;/p&gt;

&lt;p&gt;In my app, we have a prominent Facebook-like news feed which sorts by timestamp -1, and fetches activity related to the user&apos;s friends, groups, events, etc. There are many $or pieces, which combined with the sort would make the query unusable performance-wise due to this bug.&lt;/p&gt;

&lt;p&gt;I&apos;ve devised a workaround which involves a scatter-and-sort method. In PHP, each $or is broken into its own query, flattened with the non-$or conditions. This results in 12 or so indexed queries, limit 25 each. Then the results are combined and sorted back in PHP. Not ideal, it would be much better to have this done by mongo instead!&lt;/p&gt;</comment>
                            <comment id="50001" author="tdemille" created="Mon, 22 Aug 2011 21:37:51 +0000"  >&lt;p&gt;This is making a large number of my queries do full table scans..  The hint works, but I don&apos;t understand why the optimizer doesn&apos;t try that index and deduce that the index is MUCH faster?&lt;/p&gt;</comment>
                            <comment id="50000" author="tdemille" created="Mon, 22 Aug 2011 21:37:15 +0000"  >&lt;p&gt;I&apos;m not sure I understand, if the query is  {$or:[&lt;/p&gt;
{a:1}
&lt;p&gt;,&lt;/p&gt;
{b:1}
&lt;p&gt;]} ).sort( &lt;/p&gt;
{c:1}
&lt;p&gt;     and the index is &lt;/p&gt;
{a:1,b:1,c:1}
&lt;p&gt;  why wouldn&apos;t it choose that index?&lt;/p&gt;</comment>
                            <comment id="42594" author="chadrem" created="Fri, 15 Jul 2011 19:32:55 +0000"  >&lt;p&gt;This has also caused us a lot of pain.  We are current trying to come up with a workaround.&lt;/p&gt;</comment>
                            <comment id="38443" author="gotys" created="Tue, 21 Jun 2011 08:45:57 +0000"  >&lt;p&gt;This has been making my life very painful lately. Can we pease get more votes on this issue ?&lt;/p&gt;</comment>
                            <comment id="23509" author="sym3tri" created="Thu, 10 Feb 2011 01:41:50 +0000"  >&lt;p&gt;This is preventing us from running the query that we would like to run (or query with a sort), so I&apos;d just like to add my vote for a fix.&lt;/p&gt;</comment>
                            <comment id="14643" author="eliot" created="Wed, 9 Jun 2010 13:23:15 +0000"  >&lt;p&gt;this is probably less important&lt;/p&gt;</comment>
                            <comment id="14641" author="aaron" created="Wed, 9 Jun 2010 13:21:29 +0000"  >&lt;p&gt;So this means that if you do find( {$or:[&lt;/p&gt;
{a:1}
&lt;p&gt;,&lt;/p&gt;
{b:1}
&lt;p&gt;]} ).sort( &lt;/p&gt;
{c:1}
&lt;p&gt; ) we will either do a full scan of an index on c or a full table scan.  The tricky case to implement for this is when the choice is between an in memory sort scan on {$or:[&lt;/p&gt;
{a:1}
&lt;p&gt;,&lt;/p&gt;
{b:1}
&lt;p&gt;]} and a scan on index &lt;/p&gt;
{c:1}
&lt;p&gt; (possibly with a range limiter in a non or portion of the query) because we are comparing one option that is a sequence of query plans with an option that is just a single plan.&lt;/p&gt;

&lt;p&gt;Even more difficult to implement would be potentially leveraging the existing sort order inside or clauses.  For example if we wanted to do this without an in memory sort&lt;br/&gt;
find( {$or:[&lt;/p&gt;
{a:1}
&lt;p&gt;,&lt;/p&gt;
{b:1}
&lt;p&gt;]} ).sort( &lt;/p&gt;
{c:1}
&lt;p&gt; ) using indexes &lt;/p&gt;
{a:1,c:1}
&lt;p&gt; and &lt;/p&gt;
{b:1,c:1}</comment>
                            <comment id="14631" author="eliot" created="Wed, 9 Jun 2010 09:58:08 +0000"  >&lt;p&gt;Not exactly sure what you mean&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="52898">SERVER-7327</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="13610">SERVER-2057</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="131577">SERVER-13618</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="101786">SERVER-12024</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="215819">DOCS-5804</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="66858">SERVER-8790</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="33857" name="server1205.js" size="1370" author="benety.goh@mongodb.com" created="Thu, 14 Nov 2013 20:28:21 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>58.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[500A000000UaVvHIAV]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 9 Jun 2010 09:58:08 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        9 years, 42 weeks, 3 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            9 years, 42 weeks, 3 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>adro75</customfieldvalue>
            <customfieldvalue>andreas@idztech.com</customfieldvalue>
            <customfieldvalue>arie@klip.com</customfieldvalue>
            <customfieldvalue>ashishtrivedi</customfieldvalue>
            <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>burcu</customfieldvalue>
            <customfieldvalue>carlos8f</customfieldvalue>
            <customfieldvalue>chadrem</customfieldvalue>
            <customfieldvalue>gibbonsd1</customfieldvalue>
            <customfieldvalue>dan@mongodb.com</customfieldvalue>
            <customfieldvalue>drapeko</customfieldvalue>
            <customfieldvalue>sym3tri</customfieldvalue>
            <customfieldvalue>xres74</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>elsonwu</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>x2002g@gmail.com</customfieldvalue>
            <customfieldvalue>hari.khalsa@10gen.com</customfieldvalue>
            <customfieldvalue>lethum</customfieldvalue>
            <customfieldvalue>ikotev</customfieldvalue>
            <customfieldvalue>isharkov</customfieldvalue>
            <customfieldvalue>janson1983@gmail.com</customfieldvalue>
            <customfieldvalue>jhn</customfieldvalue>
            <customfieldvalue>jonathan.gaillard@dominionenterprises.com</customfieldvalue>
            <customfieldvalue>jberg</customfieldvalue>
            <customfieldvalue>nana</customfieldvalue>
            <customfieldvalue>tomliugen</customfieldvalue>
            <customfieldvalue>vaninwagen</customfieldvalue>
            <customfieldvalue>mbarrien</customfieldvalue>
            <customfieldvalue>montsechka</customfieldvalue>
            <customfieldvalue>nlyn</customfieldvalue>
            <customfieldvalue>kof</customfieldvalue>
            <customfieldvalue>oran@win.com</customfieldvalue>
            <customfieldvalue>hersha</customfieldvalue>
            <customfieldvalue>klimashkin</customfieldvalue>
            <customfieldvalue>gotys</customfieldvalue>
            <customfieldvalue>mamoos1</customfieldvalue>
            <customfieldvalue>skmasq</customfieldvalue>
            <customfieldvalue>solowu@cisco.com</customfieldvalue>
            <customfieldvalue>srini_ramamurthy@bmc.com</customfieldvalue>
            <customfieldvalue>stevemcmillen</customfieldvalue>
            <customfieldvalue>subramanyahs</customfieldvalue>
            <customfieldvalue>swaroop</customfieldvalue>
            <customfieldvalue>bonna@mail.ustc.edu.cn</customfieldvalue>
            <customfieldvalue>tdemille</customfieldvalue>
            <customfieldvalue>vramanan</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrplo7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrfuaf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5206</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hsztv3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>