Docs Menu

sh.getShardedDataDistribution()

sh.getShardedDataDistribution()

バージョン 6.0.3 で追加

シャーディングされたコレクションのデータ配信情報を返します。sh.getShardedDataDistribution() は、$shardedDataDistribution 集計パイプライン ステージのシェルヘルパー メソッドです。

You can only run the method from a mongosh session connected to a mongos instance.

このメソッドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです

重要

このコマンドは、M0、M2、M5、および Flex クラスターではサポートされていません。詳細については、「 サポートされていないコマンド 」を参照してください。

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

このメソッドの構文は次のとおりです。

sh.getShardedDataDistribution()

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:

フィールド名
データ型
説明

ns

string

シャーディングされたコレクションの名前空間。

shards

配列

各シャードのデータ配信情報を含む コレクション内の シャード 。

shards.numOrphanedDocs

integer

シャード内の 孤立したドキュメント の数。

shards.numOwnedDocuments

integer

シャードが所有するドキュメントの数。

shards.ownedSizeBytes

integer

非圧縮時にシャードが所有するドキュメントのサイズ(バイト単位)。

shards.orphanedSizeBytes

integer

シャード内の 孤立したドキュメント の非圧縮時のサイズ(バイト単位)。