You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The findAll(Pageable pageable) method on a given collection calls count() first. The count() call uses MongoDB driver's collection.countDocuments(emptyQuery) to get the result.
However MongoDB driver collection.countDocuments(emptyQuery) changed the implementation lately and uses the much slower "aggregate" query than the original "count" query.
The "count" query is very fast. And MongoDB driver added a new method collection.estimatedDocumentCount() to use "count" query.
Can we enhance findAll(Pageable pageable) to add option to use the estimatedDocumentCount()?
In my application, findAll(Pageable pageable) method(finding oldest 100 records by timestamp) runs about ~1000 times slower after driver upgrade because of the count() using MongoDB driver's exact count.