<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 07:40:16 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>[DOCS-1111] Misleading/ambiguous statement in the index page regarding sort and query</title>
                <link>https://jira.mongodb.org/browse/DOCS-1111</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;p&gt;The Indexing Strategies page (&lt;a href=&quot;http://docs.mongodb.org/manual/applications/indexes/#use-indexes-to-sort-query-results&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/applications/indexes/#use-indexes-to-sort-query-results&lt;/a&gt;) has the following statement:&lt;/p&gt;

&lt;p&gt;For queries that include a sort that uses a compound index, ensure that all fields before the first sorted field are equality matches.&lt;/p&gt;

&lt;p&gt;I verified with Aaron to decode the sentence as such:&lt;/p&gt;

&lt;p&gt;For queries that include a sort that uses a compound index, if the sortuses a subset of the index, such as .sort( &lt;/p&gt;
{ b: 1 }
&lt;p&gt; ), then to ensure&lt;br/&gt;
       that MongoDB uses the index both to retrieve and sort, the query should use equality conditions for those index fields that precede the&lt;br/&gt;
       sort index field.&lt;/p&gt;

&lt;p&gt;So, for an index of &lt;/p&gt;
{ a: 1, b: 1, c:1, d: 1 }

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;If we have a query with .sort( 
{ b: 1 }
&lt;p&gt; ), the preceding index field &apos;a&apos; should be included in the query with an equality condition:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;         db.collection.find( &lt;/p&gt;
{ a: 5 }
&lt;p&gt; ).sort( &lt;/p&gt;
{b:1 }
&lt;p&gt; )&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;If the query condition on the preceding index field is not an equality&lt;br/&gt;
  condition, MongoDB may sort the documents after it retrieves them&lt;br/&gt;
  from an index (i.e. the scanAndOrder: true)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;        db.collection.find( { a: {$gt: 5} } ).sort( &lt;/p&gt;
{ b:1 }
&lt;p&gt; )  &lt;/p&gt;

&lt;p&gt;As for the query you were specifically wondering about:&lt;/p&gt;

&lt;p&gt;        db.collection.find( &lt;/p&gt;
{ b:5 }
&lt;p&gt; ).sort( &lt;/p&gt;
{ a:1, b:1 }
&lt;p&gt; )&lt;/p&gt;

&lt;p&gt;that query uses a subset in the .sort(); however, the first index field in the sort keys is &apos;a&apos;  and in our index of &lt;/p&gt;
{ a: 1, b: 1, c:1, d: 1 }
&lt;p&gt;, there is no field&lt;br/&gt;
preceding &apos;a&apos;; so it does not need to be part of the query condition.&lt;/p&gt;
</description>
                <environment></environment>
        <key id="64881">DOCS-1111</key>
            <summary>Misleading/ambiguous statement in the index page regarding sort and query</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="kay.kim@mongodb.com">Kay Kim</assignee>
                                    <reporter username="kay.kim@mongodb.com">Kay Kim</reporter>
                        <labels>
                    </labels>
                <created>Mon, 11 Feb 2013 19:24:45 +0000</created>
                <updated>Wed, 22 Jan 2014 02:20:35 +0000</updated>
                            <resolved>Mon, 29 Jul 2013 15:41:45 +0000</resolved>
                                                    <fixVersion>v1.2</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="391242" author="auto" created="Mon, 29 Jul 2013 19:53:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;kay-kim&apos;, u&apos;name&apos;: u&apos;kay&apos;, u&apos;email&apos;: u&apos;kay.kim@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; clarify sort operations with index&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; incorporate some code review feedback&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; clarify sort operations with index&lt;/p&gt;

&lt;p&gt;Signed-off-by: Sam Kleinman &amp;lt;samk@10gen.com&amp;gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/88294e2f7ab9691bb3703ae260f4c75141d38710&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/88294e2f7ab9691bb3703ae260f4c75141d38710&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="391241" author="auto" created="Mon, 29 Jul 2013 19:53:45 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;kay-kim&apos;, u&apos;name&apos;: u&apos;kay&apos;, u&apos;email&apos;: u&apos;kay.kim@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; clarify sort operations with index&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; incorporate some code review feedback&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; clarify sort operations with index&lt;/p&gt;

&lt;p&gt;Signed-off-by: Sam Kleinman &amp;lt;samk@10gen.com&amp;gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/88294e2f7ab9691bb3703ae260f4c75141d38710&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/88294e2f7ab9691bb3703ae260f4c75141d38710&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="391240" author="auto" created="Mon, 29 Jul 2013 19:53:42 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;kay-kim&apos;, u&apos;name&apos;: u&apos;kay&apos;, u&apos;email&apos;: u&apos;kay.kim@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; clarify sort operations with index&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; incorporate some code review feedback&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-1111&quot; title=&quot;Misleading/ambiguous statement in the index page regarding sort and query&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-1111&quot;&gt;&lt;del&gt;DOCS-1111&lt;/del&gt;&lt;/a&gt; clarify sort operations with index&lt;/p&gt;

&lt;p&gt;Signed-off-by: Sam Kleinman &amp;lt;samk@10gen.com&amp;gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/88294e2f7ab9691bb3703ae260f4c75141d38710&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/88294e2f7ab9691bb3703ae260f4c75141d38710&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="75559">DOCS-1521</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>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 14 Mar 2013 23:19:41 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 29 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>kay.kim@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrs1u7:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>42528</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrybbb:</customfieldvalue>

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