Start a new topic

How to create indexes on collections for faster queries

I tried modules.collectionAccess within a custom endpoint to call ensureIndex on the collection but it seems its not available. I had assumed that since modules.collectionAccess gave direct access to MongoDB collection, the calls to create indexes would be available. Is there a way to create indexes on the collections to speed up queries?

1 person has this question

Indexes are created by a backend process which runs periodically. Short term we don't plan to offer an API for creating indexes, but if an index is right for your app it will be created on the next iteration and your app should get a lot faster.
HI Ivan



Thanks for the reply. Not sure if I understood what -"but if an index is right for your app it will be created on the next iteration" means? What criteria is used to figure what field in the entity to index on?
Well indexes are trade-offs - they tend to make the reads faster, but the writes slower. Also in some cases if the cardinality of the field(s) is low, they may not help much. When deciding to create (or drop) an index we take into account what requests you are making, are they reads vs writes, cardinality of the fields, and a few other small things.
Login or Signup to post a comment