@@ -20,32 +20,30 @@ Definition
20
20
The :method:`sh.reshardCollection()` method changes the shard key for
21
21
a collection and changes the distribution of your data.
22
22
23
+ Before you reshard a collection, read the the :ref:`reshard
24
+ requirements <reshard-requirements>` and :ref:`reshard limitations
25
+ <resharding-limitations>`.
26
+
23
27
.. |dbcommand| replace:: :dbcommand:`reshardCollection` command
24
28
.. include:: /includes/fact-mongosh-shell-method-alt.rst
25
29
26
- :method:` sh.reshardCollection()` takes the following arguments :
30
+ `` sh.reshardCollection()`` takes the following fields :
27
31
28
32
.. list-table::
29
33
:header-rows: 1
30
34
:widths: 20 20 80
31
35
32
- * - Parameter
33
-
36
+ * - Field
34
37
- Type
35
-
36
38
- Description
37
39
38
40
* - ``namespace``
39
-
40
41
- string
41
-
42
42
- The :term:`namespace` of the collection to shard in the form
43
43
``"<database>.<collection>"``.
44
44
45
45
* - ``key``
46
-
47
46
- document
48
-
49
47
- The document that specifies the new field or fields to use as the
50
48
:doc:`shard key </core/sharding-shard-key/>`.
51
49
@@ -54,44 +52,34 @@ Definition
54
52
Set the field values to either:
55
53
56
54
- ``1`` for :doc:`ranged based sharding </core/ranged-sharding>`
57
-
58
55
- ``"hashed"`` to specify a
59
56
:ref:`hashed shard key <hashed-shard-keys>`.
60
57
61
58
See also :ref:`sharding-shard-key-indexes`
62
59
63
60
* - ``unique``
64
-
65
61
- boolean
66
-
67
62
- Optional. Specify whether there is a :doc:`uniqueness
68
63
</core/index-unique>` constraint on the shard key. Only
69
64
``false`` is supported. Defaults to ``false``.
70
65
71
66
* - ``options``
72
-
73
67
- document
74
-
75
68
- Optional. A document containing optional fields, including
76
69
``numInitialChunks``, ``collation`` and ``zones``.
77
70
78
-
79
- The ``options`` argument supports the following options:
71
+ The ``options`` field supports the following fields:
80
72
81
73
.. list-table::
82
74
:header-rows: 1
83
75
:widths: 20 20 80
84
76
85
- * - Parameter
86
-
77
+ * - Field
87
78
- Type
88
-
89
79
- Description
90
80
91
81
* - ``numInitialChunks``
92
-
93
82
- integer
94
-
95
83
- Optional. Specifies the initial number of chunks to create
96
84
across all shards in the cluster when resharding a collection.
97
85
The default is the number of chunks that exist for the
@@ -100,23 +88,20 @@ The ``options`` argument supports the following options:
100
88
``numInitialChunks`` must result in less than ``8192`` per shard.
101
89
102
90
* - ``collation``
103
-
104
91
- document
105
-
106
92
- Optional. If the collection specified to ``reshardCollection``
107
93
has a default :doc:`collation </reference/collation>`,
108
94
you *must* include a collation document with
109
95
``{ locale : "simple" }``, or the ``reshardCollection``
110
96
command fails.
111
97
112
98
* - ``zones``
113
-
114
99
- array
115
-
116
100
- Optional. To maintain or add :ref:`zones <zone-sharding>`,
117
101
specify the zones for your collection in an array:
118
102
119
103
.. code-block:: javascript
104
+ :copyable: false
120
105
121
106
[
122
107
{
@@ -169,7 +154,7 @@ During the clone, apply, and catch-up phase:
169
154
170
155
.. note::
171
156
172
- If desired , you can manually force the resharding operation to
157
+ If required , you can manually force the resharding operation to
173
158
complete by issuing the :method:`sh.commitReshardCollection()`
174
159
method. This is useful if the current time estimate to complete the
175
160
resharding operation is an acceptable duration for your collection
@@ -183,8 +168,8 @@ During the clone, apply, and catch-up phase:
183
168
Commit Phase
184
169
~~~~~~~~~~~~
185
170
186
- - Once the resharding process reaches the commit phase, it may no longer
187
- be aborted with :method:`sh.abortReshardCollection()`.
171
+ - After the resharding process reaches the commit phase, the process
172
+ cannot be ended with :method:`sh.abortReshardCollection()`.
188
173
- When all shards have reached strict consistency, the resharding
189
174
coordinator commits the resharding operation and installs the new
190
175
routing table.
@@ -208,11 +193,12 @@ new shard key ``{ order_id: 1 }``:
208
193
209
194
.. code-block:: javascript
210
195
211
- sh.reshardCollection("sales.orders", { order_id: 1 })
196
+ sh.reshardCollection( "sales.orders", { order_id: 1 } )
212
197
213
- MongoDB returns the following :
198
+ Example output :
214
199
215
200
.. code-block:: javascript
201
+ :copyable: false
216
202
217
203
{
218
204
ok: 1,
0 commit comments