- Reference >
- Database Commands >
- reIndex
reIndex¶
-
reIndex
¶ The
reIndex
command rebuilds all indexes for a specified collection. Use the following syntax:Normally, MongoDB compacts indexes during routine updates. For most users, the
reIndex
command is unnecessary. However, it may be worth running if the collection size has changed significantly or if the indexes are consuming a disproportionate amount of disk space.Call
reIndex
using the following form:Warning
This command obtains a write lock on the affected database and will block other operations until it has completed.
Note
For replica sets,
reIndex
will not propagate from the primary to secondaries.reIndex
will only affect a singlemongod
instance.