Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-41854

Add expression that evaluates to shardName

    XMLWordPrintable

    Details

    • Sprint:
      Query 2019-07-29, Query 2019-10-07

      Description

      For troubleshooting and testing purposes it could be very helpful to be able to quickly check data distribution in a collection. This could be done by adding an ability to project out the shard name for a document. For example,

       

      db.employee.insert({_id: 1, name: "Joe Smith"})
      db.employee.insert({_id: 2, name: "Mary Scott"})
      db.employee.insert({_id: 3, name: "Ann Power"})
      db.employee.aggregate([{$addFields: {shardName: {$shardName: 1}}}])
      { "_id" : 1, "name" : "Joe Smith", "shardName" : "shard0" }
      { "_id" : 2, "name" : "Mary Scott", "shardName" : "shard0" }
      { "_id" : 3, "name" : "Ann Power", "shardName" : "shard1" }
      

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              anton.korshunov Anton Korshunov
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated: