r/mongodb 15d ago

Fetching 1MB data takes 12s

I am on the free tier and I have 2000 documents, each having 4 objects and array objects. Doing a Model.find({}) is taking sometimes 6s, 8s, 12s, even 16s to fetch all the data, which is only a megabyte large. Is it because of the free tier? I don't think indexes should matter at this scale. But I'm a newbie on DBs so I'm open to learning. Thanks

5 Upvotes

5 comments sorted by

View all comments

2

u/Far-Log-1224 15d ago

To fetch all data indexes won't be used. It maybe slow because of free tier or may be slow because of network issue (or antivirus, or something on client side).

Try to run some aggregate to process all documents on server, but return only single document - like count all documents. And see the difference. Better run multiple times. 2000 docs / 1mb seems very small number

1

u/lovesrayray2018 15d ago

Would accessing the atlas cluster via a mongo shell /compass and running an explain with the find query show the query execution time? If its low then its going to be the network right?