db.collection.getShardDistribution()
定義
db.collection.getShardDistribution()
重要
mongosh メソッド
このページでは、
mongosh
メソッドについて記載しています。これは Node.js などの言語固有のドライバーのドキュメントではありません。MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。
Prints the data distribution statistics for a sharded collection.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
重要
このコマンドは、M0、M2、M5、および Flex クラスターではサポートされていません。詳細については、「 サポートされていないコマンド 」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
getShardDistribution()
メソッドの形式は次のとおりです。
db.collection.getShardDistribution()
出力
注意
The behavior of getShardDistribution()
changed in MongoDB Shell
version 2.3.3:
Starting in MongoDB Shell version 2.3.3,
getShardDistribution()
only contains regular sharded data and does not account for orphaned documents.Prior to MongoDB Shell version 2.3.3,
getShardDistribution()
accounts for both regular sharded data and orphaned documents pending deletion. If the collection contains orphaned documents,getShardDistribution()
might indicate that the collection is unbalanced even if the collection is balanced in terms of regular data. The shard containing orphaned data has more documents and greater data size, but the same number of chunks compared to other shards.
Sample Output
The following is a sample output for the distribution of a sharded collection:
Shard shard01 at shard01/localhost:27018 { data: '38.14MB', docs: 1000003, chunks: 2, 'estimated data per chunk': '19.07B', 'estimated docs per chunk': 500001 } --- Shard shard02 at shard02/localhost:27019 { data: '38.14B', docs: 999999, chunks: 3, 'estimated data per chunk': '12.71B', 'estimated docs per chunk': 333333 } --- Totals { data: '76.29B', docs: 2000002, chunks: 5, 'Shard shard01': [ '50 % data', '50 % docs in cluster', '40B avg obj size on shard' ], 'Shard shard02': [ '49.99 % data', '49.99 % docs in cluster', '40B avg obj size on shard' ] }
出力フィールド
Shard shard01 at <host-a> { data: <size-a>, docs: <count-a>, chunks: <number of chunks-a>, 'estimated data per chunk': <size-a>/<number of chunks-a>, 'estimated docs per chunk': <count-a>/<number of chunks-a> } --- Shard shard02 at <host-b> { data: <size-b>, docs: <count-b>, chunks: <number of chunks-b>, 'estimated data per chunk': <size-b>/<number of chunks-b>, 'estimated docs per chunk': <count-b>/<number of chunks-b> } --- Totals { data: <stats.size>, docs: <stats.count>, chunks: <calc total chunks>, Shard shard01: [ <estDataPercent-a> % data, <estDocPercent-a> % docs in cluster, stats.shards[ <shard-a> ].avgObjSize avg obj size on shard ], Shard shard02: [ <estDataPercent-b> % data, <estDocPercent-b> % docs in cluster, stats.shards[ <shard-b> ].avgObjSize avg obj size on shard ] }
The output information displays:
出力 | 説明 | |
---|---|---|
| A string that holds the shard name. | |
| A string that holds the host name(s). | |
| A number that includes the size of the data,
including the unit of measure (e.g. | |
| A number that reports the number of documents in the shard. | |
| A number that reports the number of chunks in the shard. | |
| A calculated value that reflects the estimated data size per chunk
for the shard, including the unit of measure (e.g. | |
| A calculated value that reflects the estimated number of documents per chunk for the shard. | |
| A value that reports the total size of the data in the sharded collection, including the unit of measure. | |
| A value that reports the total number of documents in the sharded collection. | |
| A calculated number that reports the number of chunks from all shards. For example:
| |
| A calculated value that reflects, for each shard, the data size as the percentage of the collection's total data size. For example:
| |
| A calculated value that reflects, for each shard, the number of documents as the percentage of the total number of documents for the collection. For example:
| |
| A number that reflects the average object size, including the unit of measure, for the shard. |
動作
After an unclean shutdown of a mongod
using the Wired Tiger storage engine, count and size statistics reported by
db.collection.getShardDistribution()
may be inaccurate.
ドリフトの量は、チェックポイントからクリーン シャットダウンまでの間に実行された挿入、アップデート、または削除操作の数によって異なります。チェックポイントは通常、60 秒ごとに発現します。ただし、デフォルト以外の --syncdelay
設定で実行されている mongod
インスタンスでは、チェックポイントの頻度が増減する可能性があります。
不正なシャットダウン後に統計を復元するには、mongod
の各コレクションに対して validate
を実行します。
不正なシャットダウン後: