This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.
For the database command, see the
For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongoshell documentation, refer to the documentation for the corresponding MongoDB Server release:
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.
Changed in version 4.2.2.
For MongoDB 4.2.2 and later,
an exclusive (W) lock on the collection and blocks other operations on
the collection until it completes.
For more information on locking in MongoDB, see FAQ: Concurrency.