Closed
Description
Richard Kwasnicki opened DATAMONGO-2669 and commented
When using SimpleMongoRepository.count(), MongoDB is now performing a collscan instead of using estimated count by metadata. I had a short discussion with a MongoDB developer at https://developer.mongodb.com/community/forums/t/upgrading-java-mongodriver-3-x-to-4-x-leads-to-lock-with-aggregate-countstrategy/12754
He advised to never use a non-empty query on exact count and better go with MongoCollection#estimatedDocumentCount
instead of MongoCollection#countDocuments
.
For us it took minutes to perform a count query on a quite large collection on startup
Affects: 3.1.1 (2020.0.1)