-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework, Querying
-
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" }
- links to