Docs 菜单

db.collection.reIndex()

在此页面上

db.collection.reIndex()

Deprecated since version 6.0.

Attempting to run the db.collection.reIndex() method writes a warning message to the log.

重要

mongosh 方法

本页面提供 mongosh 方法的相关信息。这不是数据库命令或特定语言驱动程序(例如 Node.js)的相关文档。

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

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

The db.collection.reIndex() drops all indexes on a collection and recreates them. This operation may be expensive for collections that have a large amount of data and/or a large number of indexes.

警告

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

For MongoDB 5.0 or later, db.collection.reIndex() may only be run on 单节点 instances.

db.collection.reIndex() obtains an exclusive (W) lock on the collection and blocks other operations on the collection until it completes.

有关 MongoDB 中锁定的更多信息,请参阅常见问题解答:并发。

提示

另请参阅:

在此页面上