我想了解一下重新索引MongoDB的一些知识。请原谅我,因为我在问一些主观问题。
questinon是:MongoDB需要定期重建索引,就像我们为RDBMS做的那样,或Mongo自动管理它。
感谢您的反馈
答案 0 :(得分:5)
Mongodb在例行更新期间处理索引。这个操作 对于拥有大量数据的集合来说可能很昂贵 和/或大量索引。对于大多数用户,reIndex命令 没必要。但是,如果收集它可能值得运行 大小已经发生了显着变化,或者索引正在消耗a 不成比例的磁盘空间。
Call reIndex using the following form:
db.collection.reIndex();
参考:https://docs.mongodb.com/manual/reference/method/db.collection.reIndex/
答案 1 :(得分:4)
这是一个很好的问题,因为nowhere in the documentation明确提到索引会自动维护*。但是,他们是。你rarely need to reindex manually。
*我filed a bug for that,投票赞成:)