sh.splitFind()

On this page本页内容

Definition定义

sh.splitFind(namespace, query)

Splits the chunk that contains the shard key value specified by the query at the chunk's median point. sh.splitFind() creates two roughly equal chunks. 在块的中间点拆分包含query指定的分片键值的块。sh.splitFind()创建两个大致相等的块。To split a chunk at a specific point instead, see sh.splitAt().要在特定点拆分块,请参阅sh.splitAt()

The method takes the following arguments:该方法采用以下参数:

Parameter参数Type类型Description描述
namespacestringThe namespace (i.e. <database>.<collection>) of the sharded collection that contains the chunk to split.包含要拆分的区块的分片集合的命名空间(即<database>.<collection>)。
querydocumentA query document that specifies the shard key value that determines the chunk to split. 一个查询文档,指定确定要分割的块的分片键值。

The sh.splitFind() method wraps the split command.sh.splitFind()方法包装了split命令。

Consideration注意事项

In most circumstances, you should leave chunk splitting to the automated processes within MongoDB.在大多数情况下,应该将区块分割留给MongoDB中的自动化进程。

To use sh.splitFind(), the sharded collection must be populated.要使用sh.splitFind(),必须填充分片集合。

Example示例

For the sharded collection test.foo, the following example splits, at the median point, a chunk that contains the shard key value x: 70.对于分片集合test.foo,以下示例在中间点分割一个包含分片键值x:70的块。

sh.splitFind( "test.foo", { x: 70 } )
←  sh.splitAt()sh.startBalancer() →