sh.splitAt()
On this page本页内容
Definition定义
sh.splitAt(namespace, query)
-
Splits a chunk at the shard key value specified by the query.在查询指定的分片键值处分割块。Importantmongosh Method
This page documents a
mongosh
method. This is not the documentation for database commands or language-specific drivers, such as Node.js.For the database command, see the
split
command.For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongo
shell documentation, refer to the documentation for the corresponding MongoDB Server release: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.<database>.<collection>
)。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. 在大多数情况下,应该将区块分割留给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()
等方法手动预拆分空集合可能是有益的。
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()
.sh.splitFind()
。
Example实例
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 } )