对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

sh.splitAt()(mongosh方法)

sh.splitAt(namespace, query)

在查询指定的分片键值处分割数据块。

重要

mongosh 方法

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

有关数据库命令,请参阅 split 命令。

如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。

该方法接受以下参数:

Parameter
类型
说明

namespace

字符串

命名空间(即 <database>.<collection> )。

query

文档

一个查询文档,其中指定分割数据块的分片键值。

此方法可用于以下环境中托管的部署:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

重要

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.

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

sh.splitAt() 分割原始数据块为两个数据块。一个数据块的分片键范围从原始下限(含)开始,到指定的分片键值(不含)结束。另一个数据块的分片键范围从指定的分片键值(含)作为下限开始,到原始上限(不含)结束。

要在中点分割数据块,请参阅sh.splitFind() 。

对于分片集合test.foo ,以下示例在分片键值x: 70处分割数据段。

sh.splitAt( "test.foo", { x: 70 } )
给本页内容打分