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

Add expression that evaluates to shardName

    • Query Optimization
    • Query 2019-07-29, Query 2019-10-07

      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" }
      

       

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            anton.korshunov@mongodb.com Anton Korshunov
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: