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

Ambiguity about Where the Merge Sort Occurs in a Sharded Cluster

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • 0

      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'm misunderstanding what's being communicated, clarified.

      I believe that the mongos is the only shard that merge-sorts the results of a .find() query.

      Statements in favor of each:

      • the primary shard
        • "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."
      • the mongos
        • "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’s results before returning them to the client."

      I also note that the explanation references the $orderby option, which, according to the documentation, is deprecated as of 3.2.

            Assignee:
            andrew.feierabend@mongodb.com Andrew Feierabend (Inactive)
            Reporter:
            ravind.kumar Ravind Kumar (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:
              2 years, 1 week, 5 days ago