|
| 1 | +==================================== |
| 2 | +db.collection.getShardDistribution() |
| 3 | +==================================== |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +.. method:: db.collection.getShardDistribution() |
| 8 | + |
| 9 | + Prints the data distribution statistics for a :term:`sharded |
| 10 | + <sharding>` collection. You must call the |
| 11 | + :method:`~db.collection.getShardDistibution()` method on a sharded |
| 12 | + collection, as in the following example: |
| 13 | + |
| 14 | + .. code-block:: javascript |
| 15 | + |
| 16 | + db.myShardedCollection.getShardDistribution() |
| 17 | + |
| 18 | + In the example, the collection ``myShardedCollection`` has two |
| 19 | + shards. The output displays both the individual shard distribution |
| 20 | + information as well the total shard distribution: |
| 21 | + |
| 22 | + .. code-block:: sh |
| 23 | + |
| 24 | + Shard <shard-a> at <host-a> |
| 25 | + data : <size-a> docs : <count-a> chunks : <number of chunks-a> |
| 26 | + estimated data per chunk : <size-a>/<number of chunks-a> |
| 27 | + estimated docs per chunk : <count-a>/<number of chunks-a> |
| 28 | + |
| 29 | + Shard <shard-b> at <host-b> |
| 30 | + data : <size-b> docs : <count-b> chunks : <number of chunks-b> |
| 31 | + estimated data per chunk : <size-b>/<number of chunks-b> |
| 32 | + estimated docs per chunk : <count-b>/<number of chunks-b> |
| 33 | + |
| 34 | + Totals |
| 35 | + data : <stats.size> docs : <stats.count> chunks : <calc total chunks> |
| 36 | + Shard <shard-a> contains <estDataPercent-a>% data, <estDocPercent-a>% docs in cluster, avg obj size on shard : stats.shards[ <shard-a> ].avgObjSize |
| 37 | + Shard <shard-b> contains <estDataPercent-b>% data, <estDocPercent-b>% docs in cluster, avg obj size on shard : stats.shards[ <shard-b> ].avgObjSize |
| 38 | + |
| 39 | + The output information displays: |
| 40 | + |
| 41 | + - ``<shard-x>`` is a string value that returns the shard name. |
| 42 | + |
| 43 | + - ``<host-x>`` is a string value that returns the host name(s). |
| 44 | + |
| 45 | + - ``<size-x>`` is a numeric value that returns the size of the data, |
| 46 | + including the unit of measure (e.g. ``b``, ``Mb``). |
| 47 | + |
| 48 | + - ``<count-x>`` is a numeric value that returns the number of |
| 49 | + documents in the shard. |
| 50 | + |
| 51 | + - ``<number of chunks-x>`` is a numeric value that returns the |
| 52 | + number of chunks in the shard. |
| 53 | + |
| 54 | + - ``<size-x>/<number of chunks-x>`` is a calculated numeric value |
| 55 | + that returns the estimated data size per chunk for the shard, |
| 56 | + including the unit of measure (e.g. ``b``, ``Mb``). |
| 57 | + |
| 58 | + - ``<count-x>/<number of chunks-x>`` is a calculated numeric value |
| 59 | + that returns the estimated number of documents per chunk for the |
| 60 | + shard. |
| 61 | + |
| 62 | + - ``<stats.size>`` is a numeric value that returns the total size of |
| 63 | + the data in the sharded collection, including the unit of measure. |
| 64 | + |
| 65 | + - ``<stats.count>`` is a numeric value that returns the total number |
| 66 | + of documents in the sharded collection. |
| 67 | + |
| 68 | + - ``<calc total chunks>`` is a calculated numeric value that adds |
| 69 | + the number of chunks from the shards, for example: |
| 70 | + |
| 71 | + .. code-block:: sh |
| 72 | + |
| 73 | + <calc total chunks> = <number of chunks-a> + <number of chunks-b> |
| 74 | + |
| 75 | + - ``<estDataPercent-x>`` is a calculated numeric value that |
| 76 | + calculates, for each shard, its data size as the percentage of the |
| 77 | + collection's total data size, for example: |
| 78 | + |
| 79 | + .. code-block:: sh |
| 80 | + |
| 81 | + <estDataPercent-x> = <size-x>/<stats.size> |
| 82 | + |
| 83 | + - ``<estDocPercent-x>`` is a calculated numeric value that |
| 84 | + calculates, for each shard, the number of documents as the |
| 85 | + percentage of the total number of documents for the collection, |
| 86 | + for example: |
| 87 | + |
| 88 | + .. code-block:: sh |
| 89 | + |
| 90 | + <estDocPercent-x> = <count-x>/<stats.count> |
| 91 | + |
| 92 | + - ``stats.shards[ <shard-x> ].avgObjSize`` is a numeric value that |
| 93 | + returns the average object size, including the unit of measure, |
| 94 | + for the shard. |
| 95 | + |
| 96 | + .. seealso:: :doc:`/sharding` |
| 97 | + |
| 98 | +.. COMMENT -- not sure if I should mention the source of the data: |
| 99 | + ``shards`` collection and the ``chunks`` collection in the ``config`` database |
| 100 | + and from the :method:`db.collection.stats()` method. |
0 commit comments