Slow .findOne() with any filter with large (but few) documents

Atlas cluster deets:
VERSION 5.0.13
REGION GCP / Iowa (us-central1)
CLUSTER TIER M0 Sandbox (General)
TYPE Replica Set - 3 nodes

Connecting from the bay area.

I have a collection with ~180 documents, each relatively large sized between ~500-1500KB. Using both the NodeJS driver and MongoDB Compass, attempting to execute a find with a limit of 1 using a simple filter of any kind takes roughly 10-15 seconds to get a result. Sample filters I’ve tried:

{ date: "2022/11/11" }
{ _id: "someObjectIdGoesHere" }

(there is an index on the date field, but given the poor performance when querying for its objectid, i imagine the index is not relevant)

However, attempting to find with a limt of 1 using no filter results in a result almost instantly, as expected.

Adding a simple, small document, then querying for that document directly also completes quickly.

Since the collection only has less than 200 documents, and the filters are checking top-level fields, I would expect querying with a filter to be similarly performant.

Curious if there’s a recommended way to query for larger documents in a performant way, since that’s presumably the issue here?

if you are talking about the time to “return results”, I guess that should be something expected for the transfer of MB sized data package over the internet. Can you open a network traffic listener and check the speed when you start a query? do an internet speed test before testing your query

This might even be related to your ISP or region ISP. Can you also try importing the same (or sample) data to some free tier test clusters on same/different regions.

Also, do you have time to test your query on different times of the day? I had a month where my ISP was limiting my speed in 2-3 hours every night because they had work going on. You might have hit such an interval during your queries.

I should also mention that this happens both on my local machine (when connecting to Atlas) as well as on my live app hosted on a paid Heroku dyno. My home internet speed is ~800mb up/down so I don’t think it’s an internet speed issue.

I have tested it during different times throughout the day, by trying to use my live app - and it has been pretty consistent starting about two weeks ago. I imagine it has something to do with the size of the documents, which is why I’m curious if there’s some special way I should be querying… though at the scale I’m working at, I would hope that nothing special is needed

This might be the logical reason:
Atlas M0 (Free Cluster), M2, and M5 Limitations — MongoDB Atlas

“10GB out per seven day” then speed throttled for M0 free clusters. You can test this possibility on a new cluster importing same data.

2 Likes

Ahhhh… yup, that was it - didn’t know there were bandwidth limits. Thanks for looking out!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.