<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:11:01 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-6200] some $or queries not optimized properly</title>
                <link>https://jira.mongodb.org/browse/SERVER-6200</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;The execution plan generated for certain $or queries is amendable:&lt;/p&gt;

&lt;p&gt;&amp;gt; db.domain.ensureIndex( &lt;/p&gt;
{ key: 1 }
&lt;p&gt; )&lt;br/&gt;
&amp;gt; db.domain.find( { $or: [&lt;br/&gt;
    { key: &lt;/p&gt;
{ $gte: 722156315770, $lt: 722156332548 }
&lt;p&gt; }, { key: &lt;/p&gt;
{ $gte: 722156333548, $lt: 722156349325 }
&lt;p&gt; }, { key: &lt;/p&gt;
{ $gte: 722156416434, $lt: 722156433211 }
&lt;p&gt; },&lt;br/&gt;
    { key: &lt;/p&gt;
{ $in : [ -922337203685477, -230584300921369, -154023107256070,  115292150460684,  153726349067734,  461172215037663 ] }
&lt;p&gt; }&lt;br/&gt;
    ] } ).explain();&lt;/p&gt;

&lt;p&gt;===&amp;gt;&lt;/p&gt;

&lt;p&gt;{ clauses: [&lt;br/&gt;
{ cursor: &quot;BtreeCursor key_1&quot;, ..., indexBounds: &lt;/p&gt;
{ key: [ [  722156315770,  722156332548 ] ] }
&lt;p&gt; },&lt;br/&gt;
{ cursor: &quot;BtreeCursor key_1&quot;, ..., indexBounds: &lt;/p&gt;
{ key: [ [  722156333548,  722156349325 ] ] }
&lt;p&gt; },&lt;br/&gt;
{ cursor: &quot;BtreeCursor key_1&quot;, ..., indexBounds: &lt;/p&gt;
{ key: [ [  722156416434,  722156433211 ] ] }
&lt;p&gt; },&lt;br/&gt;
{ cursor: &quot;BtreeCursor key_1 multi&quot;, ...,  indexBounds: &lt;/p&gt;
{ key: [
    [ -922337203685477, -922337203685477 ], [ -230584300921369, -230584300921369 ], [ -154023107256070, -154023107256070 ],
    [  115292150460684,  115292150460684 ], [  153726349067734,  153726349067734 ], [  461172215037663,  461172215037663 ] ] }
&lt;p&gt; } ],&lt;br/&gt;
...&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;This is according to the docs but slow, nonetheless. I would expect the following plan&lt;/p&gt;

&lt;p&gt;{ cursor: &quot;BtreeCursor key_1 multi&quot;, ...,  indexBounds: &lt;/p&gt;
{ key: [
    [ -922337203685477, -922337203685477 ], [ -230584300921369, -230584300921369 ], [ -154023107256070, -154023107256070 ],
    [ 722156315770, 722156332548 ], [ 722156333548, 722156349325 ], [ 722156416434, 722156433211 ],
    [  115292150460684,  115292150460684 ], [  153726349067734,  153726349067734 ], [  461172215037663,  461172215037663 ] ] }
&lt;p&gt; }&lt;/p&gt;

&lt;p&gt;Which would almost halve the execution time (measured against a modified mongod where I patched the optimizer).&lt;/p&gt;

&lt;p&gt;Instead of modifying the optimizer, an alternative could also be to extend $in to accept ranges as well.&lt;/p&gt;</description>
                <environment>all</environment>
        <key id="42258">SERVER-6200</key>
            <summary>some $or queries not optimized properly</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="3">Duplicate</resolution>
                                        <assignee username="aaron">Aaron Staple</assignee>
                                    <reporter username="bjornkarge">Bj&#246;rn Karge</reporter>
                        <labels>
                    </labels>
                <created>Mon, 25 Jun 2012 05:24:58 +0000</created>
                <updated>Fri, 7 Mar 2014 00:57:33 +0000</updated>
                            <resolved>Tue, 26 Feb 2013 21:24:56 +0000</resolved>
                                    <version>2.0.6</version>
                                                    <component>Querying</component>
                                        <votes>1</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="276525" author="aaron" created="Tue, 26 Feb 2013 21:24:21 +0000"  >&lt;p&gt;Hi Bjorn - I filed a ticket for this &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-8743&quot; title=&quot;add the ability for a query to match multiple arbitrary ranges within a single index&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-8743&quot;&gt;&lt;del&gt;SERVER-8743&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="271794" author="bjornkarge" created="Thu, 21 Feb 2013 05:03:47 +0000"  >&lt;p&gt;Added the patch I mentioned on&lt;br/&gt;
&lt;a href=&quot;https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/Trn4fF0JMdM&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/Trn4fF0JMdM&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="66523">SERVER-8743</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="24285" name="queryutil.cpp.diff" size="5391" author="bjornkarge" created="Thu, 21 Feb 2013 05:03:47 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 26 Feb 2013 21:24:21 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 51 weeks, 1 day 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>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 51 weeks, 1 day 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_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>bjornkarge</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrnypj:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>10299</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|hrm8ev:</customfieldvalue>

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