-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathsh.splitAt.txt
96 lines (59 loc) · 2.2 KB
/
sh.splitAt.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
============
sh.splitAt()
============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: sh.splitAt(namespace, query)
Splits a chunk at the shard key value specified by the query.
.. |dbcommand| replace:: :dbcommand:`split` command
.. include:: /includes/fact-mongosh-shell-method-alt.rst
The method takes the following arguments:
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Parameter
- Type
- Description
* - ``namespace``
- string
- The namespace (i.e. ``<database>.<collection>``) of the sharded
collection that contains the chunk to split.
* - ``query``
- document
- A query document that specifies the :term:`shard key` value at which
to split the chunk.
Compatibility
-------------
This method is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-atlas-support-no-free.rst
.. include:: /includes/fact-environments-onprem-only.rst
Consideration
-------------
In most circumstances, you should leave chunk splitting to the
automated processes within MongoDB. However, when initially deploying a
:term:`sharded cluster`, it may be beneficial to :term:`pre-split
<pre-splitting>` manually an empty collection using methods such as
:method:`sh.splitAt()`.
Behavior
--------
:method:`sh.splitAt()` splits the original chunk into two chunks. One
chunk has a shard key range that starts with the original lower bound
(inclusive) and ends at the specified shard key value (exclusive). The
other chunk has a shard key range that starts with the specified shard
key value (inclusive) as the lower bound and ends at the original upper
bound (exclusive).
To split a chunk at its median point instead, see
:method:`sh.splitFind()`.
Example
-------
For the sharded collection ``test.foo``, the following example splits a
chunk at the shard key value ``x: 70``.
.. code-block:: javascript
sh.splitAt( "test.foo", { x: 70 } )