<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 07:53:52 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-7237] Ambiguity about Where the Merge Sort Occurs in a Sharded Cluster</title>
                <link>https://jira.mongodb.org/browse/DOCS-7237</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;p&gt;The documentation states, in different places, that a merge sort occurs on the mongos, or on the Primary database of the collection. The documentation may need to be reconciled, or, if I&apos;m misunderstanding what&apos;s being communicated, clarified.&lt;/p&gt;

&lt;p&gt;I believe that the mongos is the only shard that merge-sorts the results of a .find() query.&lt;/p&gt;

&lt;p&gt;Statements in favor of each:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.mongodb.org/manual/core/sharded-cluster-query-router/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the primary shard&lt;/a&gt;
	&lt;ul&gt;
		&lt;li&gt;&quot;If the query specifies sorted results using the sort() cursor method, the mongos instance passes the $orderby option to the shards. The primary shard for the database receives and performs a merge sort for all results before returning the data to the client via the mongos.&quot;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.mongodb.org/manual/faq/sharding/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the mongos&lt;/a&gt;
	&lt;ul&gt;
		&lt;li&gt;&quot;If you call the cursor.sort() method on a query in a sharded environment, the mongod for each shard will sort its results, and the mongos merges each shard&#8217;s results before returning them to the client.&quot;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I also note that the explanation references the $orderby option, which, according to the documentation, is &lt;a href=&quot;https://docs.mongodb.org/manual/reference/operator/meta/orderby/#metaOp._S_orderby&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;deprecated as of 3.2&lt;/a&gt;.&lt;/p&gt;</description>
                <environment></environment>
        <key id="267572">DOCS-7237</key>
            <summary>Ambiguity about Where the Merge Sort Occurs in a Sharded Cluster</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="sue.kerschbaumer@mongodb.com">Susan Kerschbaumer</assignee>
                                    <reporter username="william.cross">William Cross</reporter>
                        <labels>
                    </labels>
                <created>Tue, 23 Feb 2016 22:06:02 +0000</created>
                <updated>Thu, 14 Apr 2022 16:21:51 +0000</updated>
                            <resolved>Mon, 5 Feb 2018 19:13:39 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>9</watches>
                                                                                                                <comments>
                            <comment id="4483699" author="JIRAUSER1257477" created="Thu, 14 Apr 2022 16:21:51 +0000"  >&lt;p&gt;&lt;em&gt;Fix Version updated for upstream &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-17737&quot; title=&quot;Support distributed merger for aggregation queries&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-17737&quot;&gt;SERVER-17737&lt;/a&gt;:&lt;/em&gt; &lt;/p&gt;</comment>
                            <comment id="2028197" author="ravind.kumar" created="Tue, 9 Oct 2018 18:46:00 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=asya&quot; class=&quot;user-hover&quot; rel=&quot;asya&quot;&gt;asya&lt;/a&gt; is &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-22760&quot; title=&quot;Sharded aggregation pipelines which involve taking a simple union should merge on mongos&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-22760&quot;&gt;&lt;del&gt;SERVER-22760&lt;/del&gt;&lt;/a&gt; the ticket you were referencing? It seems like the logic behind who owns a merge sort for an aggregation pipeline has significant complexity.&lt;/p&gt;</comment>
                            <comment id="1797515" author="xgen-internal-githook" created="Tue, 6 Feb 2018 23:13:20 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;sue.kerschbaumer@10gen.com&apos;, &apos;name&apos;: &apos;skerschb&apos;, &apos;username&apos;: &apos;skerschb&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/DOCS-7237&quot; title=&quot;Ambiguity about Where the Merge Sort Occurs in a Sharded Cluster&quot; class=&quot;issue-link&quot; data-issue-key=&quot;DOCS-7237&quot;&gt;&lt;del&gt;DOCS-7237&lt;/del&gt;&lt;/a&gt; adding changes to sharded merge in 3.6&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/docs/commit/1455aa5907f91f012e77cf17f3ae3e3bd4ca1b71&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/commit/1455aa5907f91f012e77cf17f3ae3e3bd4ca1b71&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1772062" author="david.storch" created="Thu, 11 Jan 2018 20:52:48 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=bernard.gorman&quot; class=&quot;user-hover&quot; rel=&quot;bernard.gorman&quot;&gt;bernard.gorman&lt;/a&gt; completed a bunch of the work related to this in 3.6 and could be a good reviewer for proposed documentation changes.&lt;/p&gt;</comment>
                            <comment id="1770048" author="asya" created="Wed, 10 Jan 2018 12:55:49 +0000"  >&lt;p&gt;This has changed in 3.6 for aggregation and that doesn&apos;t seem to be mentioned in the docs.&lt;/p&gt;</comment>
                            <comment id="1317466" author="david.storch" created="Thu, 7 Jul 2016 21:05:11 +0000"  >&lt;p&gt;In 3.2.x versions:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;For find operations with a &lt;tt&gt;.sort()&lt;/tt&gt;, mongos will forward the sort to all participating shards. The sorted merge will then occur on mongos.&lt;/li&gt;
	&lt;li&gt;For aggregation operations, merging is always done on one of the shards. The shard which performs the merge is currently chosen at random amongst all shards in the cluster. Mongos never performs any merging for aggregation operations, but rather will simply forward the results it receives from the merging shard to the client application.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;In older versions (I think 2.6.x?) the mongos can perform merge operations, but &lt;b&gt;only for aggregation operations&lt;/b&gt;. For find operations, mongos is responsible for doing the sorted merge in all versions of MongoDB. Since both of these links are documenting find (and not aggregation), the former link appears to be inaccurate whereas the latter link is correct.&lt;/p&gt;</comment>
                            <comment id="1317171" author="ravind.kumar" created="Thu, 7 Jul 2016 18:29:33 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=david.storch&quot; class=&quot;user-hover&quot; rel=&quot;david.storch&quot;&gt;david.storch&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=renctan&quot; class=&quot;user-hover&quot; rel=&quot;renctan&quot;&gt;renctan&lt;/a&gt;, could either of you shed some light into which behavior is correct? or are both possible depending on the situation?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10320">
                    <name>Documented</name>
                                            <outwardlinks description="documents">
                                        <issuelink>
            <issuekey id="191967">SERVER-17737</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1005011">DOCS-13229</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="308297">DOCS-8582</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="644899">DOCS-12238</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="468437">DOCS-11083</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>7.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 7 Jul 2016 18:29:33 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 42 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>
                            1 year, 42 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>jess.mokrzecki@mongodb.com</customfieldvalue>
            <customfieldvalue>ravind.kumar</customfieldvalue>
            <customfieldvalue>sue.kerschbaumer@mongodb.com</customfieldvalue>
            <customfieldvalue>william.cross</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrmzbz:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1324">KANBAN BUCKET</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10555" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.5</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|hrz9jz:</customfieldvalue>

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