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.警告
db.collection.reIndex()
may only be run on 单节点 instances.For most users, the
db.collection.reIndex()
command is unnecessary.
兼容性
此方法可用于以下环境中托管的部署:
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
重要
MongoDB Atlas集群不支持此命令。 有关Atlas支持所有命令的信息,请参阅不支持的命令。
行为
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 中锁定的更多信息,请参阅常见问题解答:并发。