I am building a web app with MongoDB. When the app connects to my database, the autoIndex
flag is set to true by default. However, according to the documentation it's not recommended using it in production.
The autoIndex
flag rebuilds indexes and it affects performance. And this is fine. But why and when would I need to rebuild my indexes?
My database consists of a few documents, each one has one or more indexes. If I add a new property (with an index) to the existing schema, or create a new document schema with indexes, do I need to rebuild my indexes then, or MongoDB will automatically create indexes for new properties that need it? This part of the lifecycle is not very well explained or I haven't found a good resource about it. But I don't want to go live with my app without being fully aware of the detailed autoIndex
behaviour.