Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-7802

Conflicting documentation on sorting in a sharded cluster

      I am a TA at MongoDB U. There is conflicting and i believe dated information on how and where sorting occurs in a sharded cluster. It is our belief that with a sorted query NOT using the aggregation framework, the mongos router sends the query to the necessary shards where the results are fetched and sorted. That data is sent to the mongos router for a merge sort. If the sorted query uses the aggregation framework, each shard that is used to fetch and sort (prior to 3.2) would send the results to the primary shard for the merge sort which would then send the results to the mongos. After 3.2, if the primary shard is not used to fetch the data, the results can be sent to any of the shards that have been used for this query for the merge sort and then sent to the mongos.

      The information in the FAQ https://docs.mongodb.org/manual/faq/sharding/#how-does-mongodb-sort-queries-in-sharded-environments
      states this for non-aggregation queries.

      The information in the manual
      https://docs.mongodb.org/manual/core/sharded-cluster-query-router/
      (How mongos Handles Query Modifiers) seems to be describing the aggregation queries but does not specify that. Also on that page it is stated "Changed in version 3.2: For aggregation operations that run on multiple shards, if the operations do not require running on the database’s primary shard, these operations can route the results to any shard to merge the results and avoid overloading the primary shard for that database.".

      We believe that "How mongos Handles Query Modifiers" needs to be cleaned up to specify that this is for aggregation framework queries. it seems to be left over from earlier behavior (prior to 2.6)

      If our understanding is incorrect, please advise.

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            ms.clovis@verizon.net Michael Clovis
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              1 year, 24 weeks, 4 days ago