sh.getShardedDataDistribution()
On this page
This version of the documentation is archived and no longer supported. View the current documentation to learn how to upgrade your version of MongoDB server.
Definition
New in version 6.0.3.
Returns data distribution information for sharded collections.
sh.getShardedDataDistribution()
is a shell helper method for the
$shardedDataDistribution
aggregation pipeline stage.
You can only run the method from a mongosh
session
connected to a mongos
instance.
Syntax
The method has the following syntax:
sh.getShardedDataDistribution()
Example
The following example runs the method:
sh.getShardedDataDistribution()
The method returns an array of documents for each sharded collection. For example:
[ { ns: 'config.system.sessions', shards: [ { shardName: 'shard1', numOrphanedDocs: 0, numOwnedDocuments: 18, ownedSizeBytes: 1782, orphanedSizeBytes: 0 } ] }, { ns: 'records.people', shards: [ { shardName: 'shard1', numOrphanedDocs: 0, numOwnedDocuments: 21, ownedSizeBytes: 134, orphanedSizeBytes: 0 } ] } ]
The following table describes the output fields:
Field Name | Data Type | Description |
---|---|---|
ns | string | Namespace of the sharded collection. |
shards | array | Shards in the collection with the data distribution
information for each shard. |
shards.numOrphanedDocs | integer | Number of orphaned documents in the shard. |
shards.numOwnedDocuments | integer | Number of documents owned by the shard. |
shards.ownedSizeBytes | integer | Storage in bytes for documents owned by the shard. |
shards.orphanedSizeBytes | integer | Storage in bytes for orphaned documents in the shard. |