On this page本页内容
db.collection.
getShardDistribution
()¶mongo
Shell Method
This page documents the 本页记录了mongo
shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. mongo
shell方法,未提及MongoDB Node.js驱动程序(或任何其他驱动程序)方法。For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.有关相应的MongoDB驱动程序API,请参阅特定的MongoDB驱动程序文档。
Prints the data distribution statistics for a sharded collection.打印分片集合的数据分布统计信息。
Tip
Before running the method, use the 在运行该方法之前,请使用flushRouterConfig
command to refresh the cached routing table to avoid returning stale distribution information for the collection. flushRouterConfig
命令刷新缓存的路由表,以避免返回集合的过时分发信息。Once refreshed, run 刷新后,对要生成索引的集合运行db.collection.getShardDistribution()
for the collection you wish to build the index.db.collection.getShardDistribution()
。
For example:例如:
See also参阅
The following is a sample output for the distribution of a sharded collection:以下是分片集合分发的示例输出:
The output information displays:输出信息显示:
<shard-x>
<host-x>
<size-x>
b
, Mb
).b
,Mb
)。<count-x>
<number of chunks-x>
<size-x>/<number of chunks-x>
b
, Mb
).b
,Mb
)。<count-x>/<number of chunks-x>
<stats.size>
<stats.count>
<calc total chunks>
<estDataPercent-x>
<estDocPercent-x>
stats.shards[ <shard-x> ].avgObjSize