Reputation: 338
I have about 10,000 documents in a collection which in Mongo shell has no problem quickly querying. However, in an app that works in a browser, the queries become very slow unless I set a limit at around 100. One way to improve query speed that I've been reading online is to create indexes, but geospatial indexes already exist as it must be created in the first place to query location. What would you do in this case to improve speed in the browser? Should I create indexes for everything else as well? I wanted to throw this out there to those who may have had a similar experience. Thanks for your thoughts.
Upvotes: 2
Views: 140
Reputation: 1053
I'd try caching so that only the first load takes the time it needs while subsequent loads will be significantly shorter. Given that the size of your collection is relatively small, my assumption would be that you're importing from a json array as opposed to a regular json which separates objects by line instead of a comma. This should help reduce the size of your data significantly and in turn increase the speed of the queries. This could also save you the burden of using cloud providers by directly installing MongoDB and running the database from the remote server.
Upvotes: 2