sh.splitAt()
Definition
The method takes the following arguments:
ParameterTypeDescriptionnamespace
stringThe namespace (i.e. <database>.<collection>
) of the shardedcollection that contains the chunk to split.query
documentA query document that specifies the shard key value at whichto split the chunk.
The sh.splitAt()
method wraps the split
command.
Consideration
In most circumstances, you should leave chunk splitting to theautomated processes within MongoDB. However, when initially deploying asharded cluster, it may be beneficial to pre-split manually an empty collection using methods such assh.splitAt()
.
Behavior
sh.splitAt()
splits the original chunk into two chunks. Onechunk has a shard key range that starts with the original lower bound(inclusive) and ends at the specified shard key value (exclusive). Theother chunk has a shard key range that starts with the specified shardkey value (inclusive) as the lower bound and ends at the original upperbound (exclusive).
To split a chunk at its median point instead, seesh.splitFind()
.
Example
For the sharded collection test.foo
, the following example splits achunk at the shard key value x: 70
.
- sh.splitAt( "test.foo", { x: 70 } )