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

db. 集合.reIndex()(mongosh方法)

重要

mongosh 方法

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

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

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

db.collection.reIndex()

自版本 6.0 起已弃用。

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

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.

警告

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

重要

This command is not supported in MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

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

db.collection.reIndex() 获取集合上的独占(W)锁,并阻止集合上的其他操作,直到该操作完成。

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

提示

索引

给本页内容打分

在此页面上