Reputation: 51
I have an application with mongodb integrated with it. I need to update an index on a collection in the mongodb, and am thinking of doing it using the mongodb shell using the ensureIndex() command. I just wanted to know the consequences (if there are any) of updating an index on a live database integrated with a live application. Would it corrupt the database and in turn the application. Please let me know about it.
Thanks.
Upvotes: 0
Views: 44
Reputation: 69663
No, it won't corrupt the database. But creating an index on a very large collection can take a while and by default it will lock the whole database while the index is being built. To avoid this, you can create an index in background with the {background: true}
option. While an index is created in background, the database can operate as normal. The index won't get used until building has finished.
Upvotes: 4