Slow data downloading

Hello to all,

I am using MongoDB and I have a table with ≈ 1000 elements.

When I request my data, it takes around 2 seconds to get 1000 records from MongoDB (≈2MB, see picture). Because of this, I have a very high FCP (First Contentful Paint) on the page.

My elements are only strings or numbers, no “heavy” objects.

What should I do to optimize query speed?

P.S. new to MongoDB

Hi @Il_Chi

From the picture you posted, it looks like the 2s response was not only from MongoDB, but includes other layers as well. How did you get this 2s measurement?

I would look in the MongoDB logs to see if there are any slow query logged (MongoDB considers queries longer than 100ms to be slow, and it will be logged). If there are none, this means that the issue comes from another part of the app.

If there are slow queries logged, then next I would check if the queries are properly indexed. See indexing strategies for more details.

Best regards,
Kevin