Count Query data in a large collection

I have a very large dataset. (60M+)

Now I want to count the query data. I using collection.countDocuments(query) but it is slow

In my next js app, I wanna filter data like country and wanna show how much total data in that country.
How to retrieve the result faster??

Please share your query and the supporting indexes.

The computed pattern might be of interest.

2 Likes

@Ali_Sadain_Tanvir, is there any followup on this?