MongoDb Count Operation

I am using mongodb 4.x.x version with springboot implementation. I am using mongotemplate.count(query,class) but for more number of records like 1L Its too slow.
Any idea how to improve the performance.
I tried in eclipse its faster but not the same in Intellij??

Hi @shailee_kumari,
You can improve the performance of this operation by creating an appropriate index given your query.