<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 07:39:21 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-718] Documentation on routing of queries in the presence of only part of a compound shard key is incorrect</title>
                <link>https://jira.mongodb.org/browse/DOCS-718</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;p&gt;In &lt;a href=&quot;http://docs.mongodb.org/manual/core/sharding-internals/#sharding-internals-shard-keys&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/core/sharding-internals/#sharding-internals-shard-keys&lt;/a&gt;, the information about routing in the presence of only part of a shard key is incorrect.&lt;/p&gt;</description>
                <environment>&lt;a href=&quot;http://docs.mongodb.org/manual/core/sharding-internals/#sharding-internals-shard-keys&quot;&gt;http://docs.mongodb.org/manual/core/sharding-internals/#sharding-internals-shard-keys&lt;/a&gt;</environment>
        <key id="55335">DOCS-718</key>
            <summary>Documentation on routing of queries in the presence of only part of a compound shard key is incorrect</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="sam.kleinman">Sam Kleinman</assignee>
                                    <reporter username="william.zola@10gen.com">William Zola</reporter>
                        <labels>
                    </labels>
                <created>Mon, 5 Nov 2012 20:30:42 +0000</created>
                <updated>Thu, 8 Nov 2012 15:03:12 +0000</updated>
                            <resolved>Thu, 8 Nov 2012 15:03:12 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="184056" author="auto" created="Thu, 8 Nov 2012 15:00:45 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-11-08T15:00:34Z&apos;, u&apos;email&apos;: u&apos;samk@10gen.com&apos;, u&apos;name&apos;: u&apos;Sam Kleinman&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-718&quot; title=&quot;Documentation on routing of queries in the presence of only part of a compound shard key is incorrect&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-718&quot;&gt;&lt;del&gt;DOCS-718&lt;/del&gt;&lt;/a&gt; tweaking sharding routing text&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/bc406a4b809bc92687a2d44da1ac6e397ab97725&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/bc406a4b809bc92687a2d44da1ac6e397ab97725&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="183685" author="auto" created="Wed, 7 Nov 2012 19:05:43 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-11-07T19:05:35Z&apos;, u&apos;email&apos;: u&apos;samk@10gen.com&apos;, u&apos;name&apos;: u&apos;Sam Kleinman&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-718&quot; title=&quot;Documentation on routing of queries in the presence of only part of a compound shard key is incorrect&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-718&quot;&gt;&lt;del&gt;DOCS-718&lt;/del&gt;&lt;/a&gt; additional clarification&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/3374b3960a51472c29368b1fa5b17d6c6fe72ee3&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/3374b3960a51472c29368b1fa5b17d6c6fe72ee3&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="183329" author="auto" created="Tue, 6 Nov 2012 22:10:45 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-11-06T22:10:37Z&apos;, u&apos;email&apos;: u&apos;samk@10gen.com&apos;, u&apos;name&apos;: u&apos;Sam Kleinman&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-718&quot; title=&quot;Documentation on routing of queries in the presence of only part of a compound shard key is incorrect&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-718&quot;&gt;&lt;del&gt;DOCS-718&lt;/del&gt;&lt;/a&gt; corrections and improvements to sharded query routing cross references&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/985bdcfe82d2a95435ebc59036f1de6bb2ced546&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/985bdcfe82d2a95435ebc59036f1de6bb2ced546&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="182684" author="william.zola@10gen.com" created="Mon, 5 Nov 2012 20:33:06 +0000"  >&lt;p&gt;Here is the correct information:&lt;/p&gt;


&lt;p&gt;1) MongoDB uses the entire shard key to create an ordering of all the documents in the sharded collection. The chunks are split based on that ordering.&lt;/p&gt;

&lt;p&gt;Consider a compound shard key made up of four fields: &lt;/p&gt;
{field1:1, field2:1, field3:1, field4:1}
&lt;p&gt;.&lt;/p&gt;

&lt;p&gt;The fields of the shard key are used to create a full ordering of all the documents in the collection.  One way of thinking about this is that this shard key defines a four-digit number, with &apos;field1&apos; being the most significant digit, and &apos;field4&apos; being the least significant.&lt;/p&gt;

&lt;p&gt;If the fields that you in a query provide are sufficiently selective, then &apos;mongos&apos; will be able to route the query, at least partially. If they are not sufficiently selective, then &apos;mongos&apos; will do a scatter/gather query.&lt;/p&gt;

&lt;p&gt;This means that the only way to guarantee that a query will be a routed query if it contains all of the fields that make up the shard key.&lt;/p&gt;

&lt;p&gt;2) MongoDB will make a &quot;best effort&quot; attempt to limit the number of shards that a query will be routed to. The success of this effort depends on the specific data distribution and chunk distribution of your particular data set.&lt;/p&gt;

&lt;p&gt;This is easier to see with an example.&lt;/p&gt;

&lt;p&gt;Let&apos;s say that you&apos;re using the shard key from above: &lt;/p&gt;
{field1:1, field2:1, field3:1, field4:1}
&lt;p&gt;.  Assume a cluster containing 4 different shards. &lt;/p&gt;

&lt;p&gt;Consider what happens when you do a query of the form db.coll.find(&lt;/p&gt;
{field1:&quot;a&quot;}
&lt;p&gt; ); There are two different possibilities to consider.&lt;/p&gt;

&lt;p&gt;One is that all chunks with a shard key that contains &lt;/p&gt;
{field1:&quot;a&quot;}
&lt;p&gt; exist on a single shard; the other is that the range which contains &lt;/p&gt;
{field1:&quot;a&quot;}
&lt;p&gt; has been split (possibly on different values of &apos;field4&apos;), and the documents which contain &lt;/p&gt;
{field1:&quot;a&quot;}
&lt;p&gt; live on multiple shards. As you can see, it&apos;s easy for documents which satisfy this query to live on all 4 shards in the cluster.&lt;/p&gt;

&lt;p&gt;Given this situation, MongoDB will make a &quot;best effort&quot; attempt to limit the number of shards that have to run this query. It will do this by examining the chunk ranges for the fields that have been specified in the query, to see if it can limit the number of shards to which it will route that query.&lt;/p&gt;

&lt;p&gt;For example, based on the query &lt;/p&gt;
{field1:&quot;a&quot;}
&lt;p&gt;, the &apos;mongos&apos; process might determine that all of the documents might live on one shard; two shards; three shards; or all shards.&lt;/p&gt;

&lt;p&gt;Based on this determination, the &apos;mongos&apos; process will route the query appropriately.&lt;/p&gt;

&lt;p&gt;3) Since the chunks form a strict ordering, the key ordering is significant. In particular:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;No routing can be done if the most significant portion of the key (&apos;field1&apos; in this example) is not present&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;The greater number of shard key elements that are present (going from left to right), the higher the likelihood that the query can be routed to a subset of the shards. (For example, having both &apos;field1&apos; and &apos;field2&apos; present in the query will increase the chances that the query can be routed to a subset of the shards; adding &apos;field3&apos; will increase the chances still further.)&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Whether or not a query can be routed to a subset of shards is dependent on the data distribution, where the chunk splits are, and which chunks live on which shards&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Missing fields in the left-to-right order mean that the fields to the right cannot be used for routing. For example, if the query includes &apos;field1&apos; and &apos;field4&apos;, then &apos;field4&apos; cannot be used for routing; if the query includes &apos;field1&apos;, &apos;field2&apos; and &apos;field4&apos;, then &apos;field1&apos; and &apos;field2&apos; will be used for routing.&lt;/li&gt;
&lt;/ul&gt;




</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </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>Tue, 6 Nov 2012 22:10:45 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 14 weeks, 6 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>
                            11 years, 14 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>sam.kleinman</customfieldvalue>
            <customfieldvalue>william.zola@10gen.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrs847:</customfieldvalue>

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

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

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