In MongoDB, if collection is dropped, indexes dropped automatically as well?

Short answer: yes.

Indexes are dropping on collection drop. You need to recreate an index.

You may want to not to drop collection but remove all items in it with db.collection_name.remove({}). It will take more resources but leave your indexes. Actually it will need to delete all index data. That is why it is more preferred to drop the whole collection and recreate indexes after that.

Leave a Comment