reIndex
定義
reIndex
バージョン 6.0 から非推奨。
Attempting to run the
reIndex
command writes a warning message to the log.Tip
mongosh
では、このコマンドはdb.collection.reIndex()
ヘルパー メソッドを通じて実行することもできます。ヘルパー メソッドは
mongosh
ユーザーには便利ですが、データベースコマンドと同じレベルの情報は返されない可能性があります。 便宜上必要ない場合、または追加の戻りフィールドが必要な場合は、 データベースコマンドを使用します。The
reIndex
command 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.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
重要
このコマンドは、 MongoDB Atlasクラスターではサポートされていません。 すべてのコマンドの Atlas サポートの詳細については、「 サポートされていないコマンド 」を参照してください。
構文
このコマンドの構文は、次のとおりです。
db.runCommand( { reIndex: <collection> } )
コマンドフィールド
このコマンドは、次のフィールドを使用します。
フィールド | 説明 |
---|---|
reIndex | The name of the collection to reindex. |
動作
For MongoDB 5.0 or later, reIndex
may only be run on
スタンドアロン instances.
リソースのロック
reIndex
obtains an exclusive (W) lock on the collection and blocks
other operations on the collection until it completes.
MongoDB でのロックの詳細については、「FAQ: 同時実行性」を参照してください。
Tip
次を参照してください。
データが存在するコレクションでのインデックス構築 for more information on the behavior of indexing operations in MongoDB.