发布于 2015-09-14 15:02:52 | 257 次阅读 | 评论: 0 | 来源: 网络整理
The reIndex command rebuilds all indexes for a specified collection. Use the following syntax:
{ reIndex: "collection" }
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:
db.collection.reIndex();
警告
This command obtains a write lock on the affected database and will block other operations until it has completed.
注解
For replica sets, reIndex will not propagate from the primary to secondaries. reIndex will only affect a single mongod instance.