Q:

When to ensure_index usage in mongodb

I have a mongo db collection that is updated (a new record is added) once a second. Will it suffice to call ensure_index ONCE on the index attribute or do I have to call it repeatedly - for example after each document is added?
I understand that ensure_index looks at the last time it was invoked and potentially re-indexes the collection. What I fail to understand is why this should be necessary in my case ( or rather I don't know if this is necessary in my case). If the order of indexing or index attribute is not changing over time, do I need to repeatedly call ensure_index once for each time a new document is added?

A:

You should call it just once. In fact this method is imdepotent, which means 'once you created an index on attribute(s), repeating the same endureIndex will have no effect'

