Mongodb and indexing

北慕城南 提交于 2019-12-12 04:40:29

问题


Two questions:

  • If I remove all the data inside a collection (db.mycollection.remove({})) will the indexing information I created previously be lost?
  • How often (how many more entries must I have) should I recreate the index?

回答1:


  1. Calling remove() will remove the indexed data but not the indexes themselves (dropping a collection will do that). So when you insert new documents they will be added to the indexes you created prior to the remove() call.

  2. You don't need to recreate the index. Once you've created an index it will automatically be updated as documents are inserted / updated / removed.



来源:https://stackoverflow.com/questions/1745812/mongodb-and-indexing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!