翻译或纠错本页面

sh.splitAt()

Definition

sh.splitAt(namespace, query)

Splits a chunk at the shard key value specified by the query.

The method takes the following arguments:

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 shard key value at which to split the chunk.

Consideration

In most circumstances, you should leave chunk splitting to the automated processes within MongoDB. However, when initially deploying a sharded cluster, it may be beneficial to pre-split manually an empty collection using methods such as sh.splitAt().

Behavior

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 sh.splitFind().