I can not understand one thing. As we read in Moongose docs:
When your application starts up, Mongoose automatically calls
ensureIndex
for each defined index in your schema. While nice for development, it is recommended this behavior be disabled in production since index creation can cause a significant performance impact. Disable the behavior by setting theautoIndex
option of your schema tofalse
.
So what's the point of using
ensureIndex
by default in development, if there is preferable to disable it in production mode(more sensitive place). Shouldn't it be the oposite? We test in development and ensure that our indexes works in production?Shouldn't this method be called always? If we want to use index, and we're not sure if MongoDb created one, why we have option to use this, and this is not hard coded in Mongoose, to ensure we always have and index?
I probably misunderstood something, so I'll be gratefull for putting me straight.