<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:34:10 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-14207] Use index is order dependent</title>
                <link>https://jira.mongodb.org/browse/SERVER-14207</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;mongodb (2.6.1) use index is order dependent.&lt;/p&gt;

&lt;p&gt;in mongodb (2.4.10):&lt;br/&gt;
    indexes: (a_1), (a_1, b_1)&lt;/p&gt;

&lt;p&gt;    db.test.find(&lt;/p&gt;
{a: 1, b: 1}
&lt;p&gt;).explain()  --&amp;gt;&lt;br/&gt;
    indexBounds: (a_1, b_1)&lt;/p&gt;


&lt;p&gt;but in mongodb (2.6.1):&lt;br/&gt;
    indexes: (a_1), (a_1, b_1)&lt;/p&gt;

&lt;p&gt;    db.test.find(&lt;/p&gt;
{a: 1, b: 1}
&lt;p&gt;).explain()  --&amp;gt;&lt;br/&gt;
     indexBounds: (a_1)&lt;/p&gt;


&lt;p&gt;if I build index in reverse order:&lt;br/&gt;
    indexes: (a_1, b_1), (a_1)&lt;/p&gt;

&lt;p&gt;    db.test.find(&lt;/p&gt;
{a: 1, b: 1}
&lt;p&gt;).explain()  --&amp;gt;&lt;br/&gt;
    indexBounds: (a_1, b_1)&lt;/p&gt;</description>
                <environment></environment>
        <key id="141048">SERVER-14207</key>
            <summary>Use index is order dependent</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="9">Done</resolution>
                                        <assignee username="david.storch@mongodb.com">David Storch</assignee>
                                    <reporter username="fates.lachesis@gmail.com">Michael Yang</reporter>
                        <labels>
                    </labels>
                <created>Mon, 9 Jun 2014 09:11:26 +0000</created>
                <updated>Fri, 7 Apr 2023 14:42:43 +0000</updated>
                            <resolved>Mon, 9 Jun 2014 16:40:00 +0000</resolved>
                                    <version>2.6.1</version>
                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="614101" author="fates.lachesis@gmail.com" created="Mon, 9 Jun 2014 16:43:44 +0000"  >&lt;p&gt;thanks.&lt;/p&gt;</comment>
                            <comment id="614092" author="david.storch" created="Mon, 9 Jun 2014 16:39:46 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=fates.lachesis%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;fates.lachesis@gmail.com&quot;&gt;fates.lachesis@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thanks for your prompt response!&lt;/p&gt;

&lt;p&gt;This is more of a question about index selection in MongoDB rather than a bug in the server. I recommend redirecting your question to either StackOverflow (&lt;a href=&quot;http://stackoverflow.com/questions/tagged/mongodb&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://stackoverflow.com/questions/tagged/mongodb&lt;/a&gt;) or the MongoDB user Google Group (&lt;a href=&quot;https://groups.google.com/forum/#!forum/mongodb-user&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://groups.google.com/forum/#!forum/mongodb-user&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Some further resources that may help with indexing design are:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;The MongoDB docs indexes introduction: &lt;a href=&quot;http://docs.mongodb.org/manual/core/indexes-introduction/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/core/indexes-introduction/&lt;/a&gt;, and&lt;/li&gt;
	&lt;li&gt;a blog post from a MongoDB employee about optimizing compound indices: &lt;a href=&quot;http://emptysqua.re/blog/optimizing-mongodb-compound-indexes/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://emptysqua.re/blog/optimizing-mongodb-compound-indexes/&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;It looks to me like the two indices are tying during plan ranking, leading to the selection of index {time: 1, state: 1, get_retry_count: 1} rather than {time: 1, false_retry_count: 1}. For this reason, I am closing as Works as Designed.&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Dave&lt;/p&gt;</comment>
                            <comment id="613969" author="fates.lachesis@gmail.com" created="Mon, 9 Jun 2014 15:29:51 +0000"  >&lt;p&gt;the problem is mongodb log report wait a/b lock when findAndModify document,&lt;br/&gt;
I have 200000 document in same collection,&lt;br/&gt;
and have 200 connection in the same time.&lt;br/&gt;
the document like below:&lt;br/&gt;
{&lt;br/&gt;
    time: isodate(),&lt;br/&gt;
    state: 1,&lt;br/&gt;
    false_retry_count: 10,&lt;br/&gt;
    get_retry_count: 10,&lt;br/&gt;
    .............&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;index if like below:&lt;br/&gt;
idx1: (time_1, state_1, get_retry_count_1),  idx2: (time_1, false_retry_count_1)&lt;/p&gt;

&lt;p&gt;db.test.find({false_retry_count: 1, time:{$gt: ....}}),explain();&lt;br/&gt;
mongodb (2.6.1) chose idx1 not idx2,&lt;br/&gt;
but mongodb (2.4.10) chose idx2.&lt;/p&gt;


&lt;p&gt;the way to avoid the a/b lock problem,&lt;br/&gt;
I have change the order of index like below:&lt;br/&gt;
idx1: (state_1, time_1, get_retry_count_1),  idx2: (time_1, false_retry_count_1)&lt;br/&gt;
--&amp;gt; let prefix match idx2.&lt;br/&gt;
--&amp;gt; and I don&apos;t see the problem again.&lt;/p&gt;

&lt;p&gt;if I chose time as shard key,&lt;br/&gt;
other index with time and build after time index build,&lt;br/&gt;
will be non usable.&lt;/p&gt;</comment>
                            <comment id="613899" author="david.storch" created="Mon, 9 Jun 2014 14:35:52 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=flachesis&quot; class=&quot;user-hover&quot; rel=&quot;flachesis&quot;&gt;flachesis&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thanks for the bug report. It looks as though in 2.6.1 the two indices, {a: 1} and {a: 1, b: 1} are tying during plan ranking. Assuming that the indices are equally good candidates to answer the query, the ranker will choose one of the tying plans arbitrarily. It so happens as an implementation artifact that the ranker will choose the index that was built first (but this is not documented behavior, and should not be relied upon). If my suspicion about tying plans is correct, then this is working as designed.&lt;/p&gt;

&lt;p&gt;A little bit of background on why this behavior changed: in 2.4.x versions, there was a hack in which an index would always be used if the query shape exactly matched the index key pattern. This hack was removed as part of the query engine refactor for 2.6 in favor of a much more general plan ranker.&lt;/p&gt;

&lt;p&gt;What is the data in your collection? Are your test collections empty other than the indices?&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Dave&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="141047">SERVER-14206</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 9 Jun 2014 14:24:06 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        9 years, 36 weeks, 2 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, 36 weeks, 2 days 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>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>fates.lachesis@gmail.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrltjr:</customfieldvalue>

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

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

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