Docs Menu
Docs Home
MongoDB Manual
/ / /


On this page

  • Definition
  • Compatibility
  • Syntax
  • Command Fields
  • Behavior

Deprecated since version 6.0.

Attempting to run the reIndex command writes a warning message to the log.


In mongosh, this command can also be run through the db.collection.reIndex() helper method.

Helper methods are convenient for mongosh users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.

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.


  • reIndex may only be run on standalone instances.

  • For most users, the reIndex command is unnecessary.

This command is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud


This command is not supported in M0, M2, and M5 clusters. For more information, see Unsupported Commands.

The command has the following syntax:

reIndex: <collection>

The command takes the following fields:

The name of the collection to reindex.

For MongoDB 5.0 or later, reIndex may only be run on standalone instances.

reIndex obtains 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.



Index Builds on Populated Collections for more information on the behavior of indexing operations in MongoDB.

← logRotate