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
* This method uses an {@link com.mongodb.client.MongoCollection#countDocuments(org.bson.conversions.Bson, com.mongodb.client.model.CountOptions) aggregation
130
+
* execution} even for empty {@link Query queries} which may have an impact on performance, but guarantees shard,
131
+
* session and transaction compliance. In case an inaccurate count satisfies the applications needs use
132
+
* {@link MongoOperations#estimatedCount(String)} for empty queries instead.
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/mongodb.adoc
+1
Original file line number
Diff line number
Diff line change
@@ -2221,6 +2221,7 @@ With the introduction of <<mongo.transactions>> this was no longer possible beca
2221
2221
So in version 2.x `MongoOperations.count()` would use the collection statistics if no transaction was in progress, and the aggregation variant if so.
2222
2222
2223
2223
As of Spring Data MongoDB 3.x any `count` operation uses regardless the existence of filter criteria the aggregation-based count approach via MongoDBs `countDocuments`.
2224
+
If the application is fine with the limitations of working upon collection statistics `MongoOperations.estimatedCount()` offers an alternative.
0 commit comments