I\'m using MongoDB for our web application. Assume there will be a \'find()\' on MongoDB for incoming requests. What is the recommended way/place to add index on a MongoDB c
Clearly run the ensureIndex when you start the application. It doesn't matter if you call the ensureIndex on an empty collection (as it will add the data afterwards to the index).
Furthermore it depends on which property your queries are based. If you for example query based on the logged in user, then you should add the index on the user id.