Skip to content

Shard 1 #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/reference/javascript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ that you may use with collection objects.
.. include:: method/getShardVersion.txt
:start-after: mongodb

.. include:: method/getShardDistribution.txt
.. include:: method/db.collection.getShardDistribution.txt
:start-after: mongodb

.. include:: method/db.collection.stats.txt
Expand Down
120 changes: 120 additions & 0 deletions source/reference/method/db.collection.getShardDistribution.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
====================================
db.collection.getShardDistribution()
====================================

.. default-domain:: mongodb

.. method:: db.collection.getShardDistribution()

Prints the data distribution statistics for a :term:`sharded
<sharding>` collection. You must call the
:method:`~db.collection.getShardDistibution()` method on a sharded
collection, as in the following example:

.. code-block:: javascript

db.myShardedCollection.getShardDistribution()

In the example, the collection ``myShardedCollection`` has two
shards. The output displays both the individual shard distribution
information as well the total shard distribution:

.. code-block:: sh

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

The output information displays:

- ``<shard-x>`` is a string value that returns the shard name.

- ``<host-x>`` is a string value that returns the host name(s).

- ``<size-x>`` is a numeric value that returns the size of the data,
including the unit of measure (e.g. ``b``, ``Mb``).

- ``<count-x>`` is a numeric value that returns the number of
documents in the shard.

- ``<number of chunks-x>`` is a numeric value that returns the
number of chunks in the shard.

- ``<size-x>/<number of chunks-x>`` is a calculated numeric value
that returns the estimated data size per chunk for the shard,
including the unit of measure (e.g. ``b``, ``Mb``).

- ``<count-x>/<number of chunks-x>`` is a calculated numeric value
that returns the estimated number of documents per chunk for the
shard.

- ``<stats.size>`` is a numeric value that returns the total size of
the data in the sharded collection, including the unit of measure.

- ``<stats.count>`` is a numeric value that returns the total number
of documents in the sharded collection.

- ``<calc total chunks>`` is a calculated numeric value that adds
the number of chunks from the shards, for example:

.. code-block:: sh

<calc total chunks> = <number of chunks-a> + <number of chunks-b>

- ``<estDataPercent-x>`` is a calculated numeric value that
calculates, for each shard, its data size as the percentage of the
collection's total data size, for example:

.. code-block:: sh

<estDataPercent-x> = <size-x>/<stats.size>

- ``<estDocPercent-x>`` is a calculated numeric value that
calculates, for each shard, the number of documents as the
percentage of the total number of documents for the collection,
for example:

.. code-block:: sh

<estDocPercent-x> = <count-x>/<stats.count>

- ``stats.shards[ <shard-x> ].avgObjSize`` is a numeric value that
returns the average object size, including the unit of measure,
for the shard.

For example, the following is a sample output for the distribution
of a sharded collection:

.. code-block:: sh

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

.. seealso:: :doc:`/sharding`

.. COMMENT -- not sure if I should mention the source of the data:
``shards`` collection and the ``chunks`` collection in the ``config`` database
and from the :method:`db.collection.stats()` method.
9 changes: 0 additions & 9 deletions source/reference/method/getShardDistribution.txt

This file was deleted.