<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:37:38 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-15300] Wrong index is being used, causing inefficient queries</title>
                <link>https://jira.mongodb.org/browse/SERVER-15300</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I have a collection with two fields. One is a string and another is an ObjectId.&lt;br/&gt;
I have indices on both fields.&lt;br/&gt;
When doing a query such as {&apos;string_field&apos; : &apos;some value&apos;, &apos;other_obj_id&apos; : {$exists : true}}, the index used for the query is consistently the one on &apos;other_obj_id&apos; and not the one on &apos;string_field&apos;, although that one would be much faster.&lt;/p&gt;

&lt;p&gt;This staretd to happen as soon as I&apos;ve upgraded to 2.6.4 and is a degradation from 2.6.1 !&lt;/p&gt;</description>
                <environment></environment>
        <key id="158842">SERVER-15300</key>
            <summary>Wrong index is being used, causing inefficient queries</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="ramon.fernandez@mongodb.com">Ramon Fernandez Marina</assignee>
                                    <reporter username="baruchoxman">Baruch Oxman</reporter>
                        <labels>
                    </labels>
                <created>Thu, 18 Sep 2014 11:48:57 +0000</created>
                <updated>Tue, 28 Oct 2014 19:55:06 +0000</updated>
                            <resolved>Tue, 28 Oct 2014 19:55:06 +0000</resolved>
                                    <version>2.6.4</version>
                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="750785" author="ramon.fernandez" created="Tue, 28 Oct 2014 19:54:35 +0000"  >&lt;p&gt;Understood, thanks for letting us know &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=baruchoxman&quot; class=&quot;user-hover&quot; rel=&quot;baruchoxman&quot;&gt;baruchoxman&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="750728" author="baruchoxman" created="Tue, 28 Oct 2014 19:00:52 +0000"  >&lt;p&gt;Indeed looks like a duplicate of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14961&quot; title=&quot;Plan ranker favors intersection plans if predicate generates empty range index scan&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14961&quot;&gt;&lt;del&gt;SERVER-14961&lt;/del&gt;&lt;/a&gt;. I&apos;ve upgraded to 2.6.5, so&lt;br/&gt;
feel free to close and I&apos;ll reopen with the additional information if I&lt;br/&gt;
still encounter it after the upgrade.&lt;/p&gt;

&lt;p&gt;On Tue, Oct 28, 2014 at 8:50 PM, Ramon Fernandez (JIRA) &amp;lt;jira@mongodb.org&amp;gt;&lt;/p&gt;
</comment>
                            <comment id="750707" author="ramon.fernandez" created="Tue, 28 Oct 2014 18:48:22 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=baruchoxman&quot; class=&quot;user-hover&quot; rel=&quot;baruchoxman&quot;&gt;baruchoxman&lt;/a&gt;, we haven&apos;t heard back from you for a while? Is this still an issue for you? Have you had a chance to look into &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14961&quot; title=&quot;Plan ranker favors intersection plans if predicate generates empty range index scan&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14961&quot;&gt;&lt;del&gt;SERVER-14961&lt;/del&gt;&lt;/a&gt;? If this is still an issue, can you please post the output of &lt;tt&gt;explain()&lt;/tt&gt; for one of those queries where you see degraded performance?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Ram&#243;n.&lt;/p&gt;</comment>
                            <comment id="727398" author="ramon.fernandez" created="Thu, 25 Sep 2014 19:40:18 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=baruchoxman&quot; class=&quot;user-hover&quot; rel=&quot;baruchoxman&quot;&gt;baruchoxman&lt;/a&gt;, can you post the output of &lt;tt&gt;explain()&lt;/tt&gt; for one of these queries? I&apos;m suspecting you may be running into &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14961&quot; title=&quot;Plan ranker favors intersection plans if predicate generates empty range index scan&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14961&quot;&gt;&lt;del&gt;SERVER-14961&lt;/del&gt;&lt;/a&gt;. If the plan ranker is choosing to do index intersection that could explain the performance degradation you&apos;re seeing. Note also that &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14961&quot; title=&quot;Plan ranker favors intersection plans if predicate generates empty range index scan&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14961&quot;&gt;&lt;del&gt;SERVER-14961&lt;/del&gt;&lt;/a&gt; offers a possible workaround &amp;#8211; could you please try to run your queries before and after disabling index intersection to see if this is the root cause of the issue?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Ram&#243;n.&lt;/p&gt;</comment>
                            <comment id="724372" author="baruchoxman" created="Mon, 22 Sep 2014 19:09:00 +0000"  >&lt;p&gt;I don&apos;t have it ready now, as I changed my queries in the meantime, by creating a compound index on both fields (which solved the problem).&lt;/p&gt;

&lt;p&gt;I read about the way mongo decides which index to use, and that it has a &quot;preferred index&quot; for each query, that gets invalidated after 1000 writes to the collection, so could be that the slow instances I saw were these queries where the queries optimizer had to decide which index to use.&lt;br/&gt;
But still, I am sure it should do better when one part of the query is a specific value, and the other is an $exists clause.&lt;/p&gt;

&lt;p&gt;To my understanding, this would be reproduced with any collection with a large amount of documents (let&apos;s say 500,000), where there are two fields: &quot;a&quot; - with a string value, and an additional &quot;obj_id&quot; value, which might either exist or not, and there are individual indices on both fields.&lt;/p&gt;</comment>
                            <comment id="724334" author="ramon.fernandez" created="Mon, 22 Sep 2014 18:42:11 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=baruchoxman&quot; class=&quot;user-hover&quot; rel=&quot;baruchoxman&quot;&gt;baruchoxman&lt;/a&gt;, do you have a reproducer with a few sample documents that shows the behavior you describe?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="153664">SERVER-14961</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 22 Sep 2014 18:42:11 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        9 years, 16 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>
                            9 years, 16 weeks, 1 day ago
                        </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>baruchoxman</customfieldvalue>
            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrlnpz:</customfieldvalue>

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

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

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