Docs HomeMongoDB Manual

sh.enableAutoMerger()

Definition定义

sh.enableAutoMerger(namespace)

New in version 7.0. 7.0版新增。

Enables automatic chunk merges for a namespace.启用命名空间的自动合并。

sh.enableAutoMerger() is a mongosh helper method. 是一个mongosh辅助方法。It is effectively the same as running the configureCollectionBalancing command with the enableAutoMerger field set to true.这实际上与在enableAutoMerger字段设置为true的情况下运行configureCollectionBalancing命令相同。

Important

mongosh 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 configureCollectionBalancing 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:

mongo shell v4.4

Syntax语法

sh.enableAutoMerger( <namespace> )

Method Field方法字段

The method takes the following field:该方法采用以下字段:

Field字段Type类型Necessity必要性Description描述
namespaceStringRequired必要的Namespace in the format "<database>.<collection>". Method enables automatic chunk merges for the supplied namespace.格式为"<database>.<collection>"的命名空间。方法为所提供的命名空间启用自动块合并。

Behavior行为

To set the time intervals for automatic chunk merges, use these parameters:要设置自动块合并的时间间隔,请使用以下参数:

Example实例

The following example enables automatic chunk merges for "testDatabase.myCollection". 以下示例为"testDatabase.myCollection"启用了自动块合并。Run the example from mongos:运行mongos中的示例:

sh.enableAutoMerger( "testDatabase.myCollection" )

Learn More了解更多信息