重要
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.警告
db.collection.reIndex()may only be run on standalone instances.For most users, the
db.collection.reIndex()command is unnecessary.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
重要
このコマンドは、MongoDB Atlas クラスターではサポートされていません。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
動作
MongoDB5.0 以降の場合、db.collection.reIndex() はスタンドアロンインスタンスでのみ実行できます。
リソースのロック
db.collection.reIndex() はコレクションに対して排他的ロック(W)を取得し、完了するまでコレクションに対する他の操作をブロックします。
MongoDB でのロックの詳細については、「FAQ: 同時実行性」を参照してください。
Tip