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
Hey Erik T, thanks for raising this issue. Reusing the count from QueryResults makes sense. Going forward with this topic we could use fetch() instead and retrieve the count only if necessary
Erik T opened DATAMONGO-1860 and commented
https://github.com/spring-projects/spring-data-mongodb/blob/master/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QuerydslMongoPredicateExecutor.java#L172
Count is a very expensive operation in MongoDB https://jira.mongodb.org/browse/SERVER-1752
In snippet above, fetchResults() internally calls count to populate total count of QueryResults.
Again, fetchCount also calls count.
would end up calling count once.
Moreover, giving the option of returning Slice<T> as well as Page<T>, and do away with count altogether would also be a nice addition.
Affects: 2.0.3 (Kay SR3)
Reference URL: https://github.com/spring-projects/spring-data-mongodb/blob/master/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QuerydslMongoPredicateExecutor.java#L172
Referenced from: pull request #529
Backported to: 2.0.4 (Kay SR4), 1.10.11 (Ingalls SR11)
The text was updated successfully, but these errors were encountered: