On this page本页内容
sh.splitAt(namespace, query) Splits a chunk at the shard key value specified by the query.在查询指定的分片键值处拆分块。
The method takes the following arguments:该方法采用以下参数:
namespace | string | <database>.<collection>) of the sharded collection that contains the chunk to split.<database>.<collection>)。 |
query | document |
The sh.splitAt() method wraps the split command.sh.splitAt()方法包装了split命令。
In most circumstances, you should leave chunk splitting to the automated processes within MongoDB. 在大多数情况下,应该将区块分割留给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().sh.splitAt()等方法手动预拆分空集合可能会有所帮助。
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().sh.splitFind()。
For the sharded collection 对于分片集合test.foo, the following example splits a chunk at the shard key value x: 70.test.foo,以下示例在分片键值x:70处拆分块。
sh.splitAt( "test.foo", { x: 70 } )