Query is taking 40 seconds to complete and find 70k items

Hello everyone. I’m relatively new to working with such a large amount of data in MongoDB, and I have a query that retrieves around 70,000 items. However, this query is taking approximately 40 seconds to complete. I’ve created a compound index for this query, and it appears to be in use. While everything seems to be functioning correctly, I’m wondering if this execution time of 40 seconds is reasonable for fetching this amount of data, or if there’s potential to improve its speed. Does anyone have any insights on this matter?

Hey @satoru_turing,

Welcome to the MongoDB Community!

Could you please share

  • the sample document,
  • the compound index you have created,
  • the query you are executing, and
  • the explain output of the query?

This information will help us to assist you further.

Please also let us know which version of MongoDB you are working with and whether you are executing the queries through mongosh or using any language driver.