Why mongodb taking 2-3 seconds to fetch only 100 documents?

I’m new to mongodb and i’m currently using mongodb free m0 atlas cluster while fetching only 100 documents out of 7000+ documents it’s taking like 2-3 seconds.

I’m fetching it from my node.js application using mongoose.


I’m not using any kind of join, etc it’s simple find query here it is:

await coinsDetail.find({}).sort({ 'rank': 1 })
    .select({ name: 1, symbol: 1, slug: 1, quotesUsd: 1, quotesBtc: 1, quotesEth: 1, supply: 1, highLow: 1, maxSupply: 1, status: 1, cmcCoinDbId: 1 })

please help if anyone had experience this?

Is it because of mongodb free cluster? i don’t think so because only i’m the one who is using the database so why this happened?

Thank you!


are in contradiction. Your find asks for all documents.

@steevej i want to sort it by rank and then limit 100. I think this query is okay but i don’t know why taking so much time.

Sorry. I really missed the limit(limit) at the end.

I am not familiar with the select() method. It looks like project(). Are you using mongoose or another layer? Try running the query in mongosh or mongo to get the explain plan.

Do you have an index on rank? If so you might try to give it as an index hint to make sure it uses it for sort.