db.collection.getShardDistribution()

在本页面

Definition

  • db.collection. getShardDistribution ( )
    • 打印sharded集合的数据分布统计信息。

Tip

在运行该方法之前,请使用flushRouterConfig命令刷新缓存的路由表,以避免返回该集合的陈旧分发信息。刷新后,对要构建索引的集合运行db.collection.getShardDistribution()

For example:

db.adminCommand( { flushRouterConfig: "test.myShardedCollection" } );
db.getSiblingDB("test").myShardedCollection.getShardDistribution();

See also

Output

Sample Output

以下是分发分片集合的示例输出:

Shard shard-a at shard-a/MyMachine.local:30000,MyMachine.local:30001,MyMachine.local:30002
data : 38.14Mb docs : 1000003 chunks : 2
estimated data per chunk : 19.07Mb
estimated docs per chunk : 500001

Shard shard-b at shard-b/MyMachine.local:30100,MyMachine.local:30101,MyMachine.local:30102
data : 38.14Mb docs : 999999 chunks : 3
estimated data per chunk : 12.71Mb
estimated docs per chunk : 333333

Totals
data : 76.29Mb docs : 2000002 chunks : 5
Shard shard-a contains 50% data, 50% docs in cluster, avg obj size on shard : 40b
Shard shard-b contains 49.99% data, 49.99% docs in cluster, avg obj size on shard : 40b

Output Fields

Shard <shard-a> 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 <shard-b> 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 <shard-a> contains  <estDataPercent-a>% data, <estDocPercent-a>% docs in cluster, avg obj size on shard : stats.shards[ <shard-a> ].avgObjSize
 Shard <shard-b> contains  <estDataPercent-b>% data, <estDocPercent-b>% docs in cluster, avg obj size on shard : stats.shards[ <shard-b> ].avgObjSize

输出信息显示:

  • <shard-x>是包含分片名称的字符串。

  • <host-x>是包含主机名的字符串。

  • <size-x>是一个数字,其中包括数据的大小,包括度量单位(例如bMb)。

  • <count-x>是报告分片中文档数量的数字。

  • <number of chunks-x>是一个数字,报告分片中的块数。

  • <size-x>/<number of chunks-x>是一个计算值,反映了该分片每块的估计数据大小,包括度量单位(例如bMb)。

  • <count-x>/<number of chunks-x>是一个计算值,反映了该分片每块的估计文档数。

  • <stats.size>是一个值,用于报告分片集合中数据的总大小,包括度量单位。

  • <stats.count>是一个值,用于报告分片集合中的文档总数。

  • <calc total chunks>是计算得出的数字,它报告所有分片中的块数,例如:

<calc total chunks> = <number of chunks-a> + <number of chunks-b>
  • <estDataPercent-x>是一个计算值,该值反映每个分片的数据大小占集合总数据大小的百分比,例如:
<estDataPercent-x> = <size-x>/<stats.size>
  • <estDocPercent-x>是一个计算值,该值反映每个分片的文档数占集合文档总数的百分比,例如:
<estDocPercent-x> = <count-x>/<stats.count>
  • stats.shards[ <shard-x> ].avgObjSize是反映分片平均对象大小(包括度量单位)的数字。