Skip to content

Commit 6bbe521

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-25130-sharded-data-method (#5681) (#5757)
* DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method * DOCSP-25130-sharded-data-method --------- Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
1 parent 16b7508 commit 6bbe521

File tree

7 files changed

+135
-33
lines changed

7 files changed

+135
-33
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Returns data distribution information for sharded collections.
2+
``sh.getShardedDataDistribution()`` is a shell helper method for the
3+
:pipeline:`$shardedDataDistribution` aggregation pipeline stage.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. list-table::
2+
:header-rows: 1
3+
:widths: 30 15 55
4+
5+
* - Field Name
6+
- Data Type
7+
- Description
8+
9+
* - ``ns``
10+
- string
11+
- Namespace of the sharded collection.
12+
13+
* - ``shards``
14+
- array
15+
- Shards in the collection with the data distribution
16+
information for each shard.
17+
18+
* - ``shards.numOrphanedDocs``
19+
- integer
20+
- Number of orphaned documents in the shard.
21+
22+
* - ``shards.numOwnedDocuments``
23+
- integer
24+
- Number of documents owned by the shard.
25+
26+
* - ``shards.ownedSizeBytes``
27+
- integer
28+
- Storage in bytes for documents owned by the shard.
29+
30+
* - ``shards.orphanedSizeBytes``
31+
- integer
32+
- Storage in bytes for orphaned documents in the shard.

source/reference/method.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,10 @@ Sharding
10031003

10041004
- Returns a boolean to report if the :term:`balancer` is currently enabled.
10051005

1006+
* - :method:`sh.getShardedDataDistribution()`
1007+
1008+
- .. include:: /includes/sharding/getShardedDataDistribution-shell-helper-method-summary.rst
1009+
10061010
* - :method:`sh.removeTagRange()`
10071011

10081012
- In MongoDB 3.4, this method aliases to :method:`sh.removeRangeFromZone()`.

source/reference/method/js-sharding.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ Sharding Methods
115115

116116
- Returns a boolean to report if the :term:`balancer` is currently enabled.
117117

118+
* - :method:`sh.getShardedDataDistribution()`
119+
120+
- .. include:: /includes/sharding/getShardedDataDistribution-shell-helper-method-summary.rst
121+
118122
* - :method:`sh.removeTagRange()`
119123

120124
- This method aliases to :method:`sh.removeRangeFromZone()`.
@@ -234,6 +238,7 @@ Sharding Methods
234238
/reference/method/sh.enableAutoSplit
235239
/reference/method/sh.enableSharding
236240
/reference/method/sh.getBalancerState
241+
/reference/method/sh.getShardedDataDistribution
237242
/reference/method/sh.help
238243
/reference/method/sh.isBalancerRunning
239244
/reference/method/sh.moveChunk
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
===============================
2+
sh.getShardedDataDistribution()
3+
===============================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. method:: sh.getShardedDataDistribution()
17+
18+
.. versionadded:: 6.0.3
19+
20+
.. include:: /includes/sharding/getShardedDataDistribution-shell-helper-method-summary.rst
21+
22+
You can only run the method from a :binary:`~bin.mongosh` session
23+
connected to a :binary:`~bin.mongos` instance.
24+
25+
Syntax
26+
------
27+
28+
The method has the following syntax:
29+
30+
.. code-block:: javascript
31+
32+
sh.getShardedDataDistribution()
33+
34+
Example
35+
-------
36+
37+
The following example runs the method:
38+
39+
.. code-block:: javascript
40+
41+
sh.getShardedDataDistribution()
42+
43+
The method returns an array of documents for each sharded collection.
44+
For example:
45+
46+
.. code-block:: javascript
47+
48+
[
49+
{
50+
ns: 'config.system.sessions',
51+
shards: [
52+
{
53+
shardName: 'shard1',
54+
numOrphanedDocs: 0,
55+
numOwnedDocuments: 18,
56+
ownedSizeBytes: 1782,
57+
orphanedSizeBytes: 0
58+
}
59+
]
60+
},
61+
{
62+
ns: 'records.people',
63+
shards: [
64+
{
65+
shardName: 'shard1',
66+
numOrphanedDocs: 0,
67+
numOwnedDocuments: 21,
68+
ownedSizeBytes: 134,
69+
orphanedSizeBytes: 0
70+
}
71+
]
72+
}
73+
]
74+
75+
The following table describes the output fields:
76+
77+
.. include:: /includes/sharding/shardedDataDistribution-output.rst
78+
79+
Learn More
80+
----------
81+
82+
- :pipeline:`$shardedDataDistribution`
83+
- :method:`sh.enableSharding()`
84+
- :method:`sh.addShard()`
85+
- :method:`sh.shardCollection()`
86+
- :method:`sh.reshardCollection()`

source/reference/operator/aggregation/shardedDataDistribution.txt

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,7 @@ The ``$shardedDataDistribution`` stage outputs an array of documents
4646
for each sharded collection in the database. These documents contain the
4747
following fields:
4848

49-
.. list-table::
50-
:header-rows: 1
51-
:widths: 30 15 55
52-
53-
* - Field Name
54-
- Data Type
55-
- Description
56-
57-
* - ``ns``
58-
- string
59-
- The namespace of the sharded collection.
60-
61-
* - ``shards``
62-
- array
63-
- Lists the shards in the collection with data distribution information
64-
on each shard.
65-
66-
* - ``shards.numOrphanedDocs``
67-
- integer
68-
- Number of orphaned documents in the shard.
69-
70-
* - ``shards.numOwnedDocuments``
71-
- integer
72-
- Number of documents owned by the shard.
73-
74-
* - ``shards.orphanedSizeBytes``
75-
- integer
76-
- Amount of storage in bytes used by orphaned documents in the shard.
77-
78-
* - ``shards.ownedSizeBytes``
79-
- integer
80-
- Amount of storage in bytes used by owned documents in the shard.
81-
49+
.. include:: /includes/sharding/shardedDataDistribution-output.rst
8250

8351
Examples
8452
--------

source/reference/sharding.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ Sharding Methods in ``mongosh``
9999

100100
- Returns a boolean to report if the :term:`balancer` is currently enabled.
101101

102+
* - :method:`sh.getShardedDataDistribution()`
103+
104+
- .. include:: /includes/sharding/getShardedDataDistribution-shell-helper-method-summary.rst
105+
102106
* - :method:`sh.removeTagRange()`
103107

104108
- In MongoDB 3.4, this method aliases to :method:`sh.removeRangeFromZone()`.

0 commit comments

Comments
 (0)