-
-
Notifications
You must be signed in to change notification settings - Fork 514
Open
Labels
Description
This was previously handled in #1086 for 1.x, but can't be done in 2.0 for repository methods (they are expected to return a cursor which no longer offers triggering a count query).
While this performance improvement can lead to situations where counting gives one results and a subsequent iteration over the collection yields more results than previously counted, it is definitely not a good idea to read (and hydrate) all results just to count them.
A workaround may be to load data into memory but not hydrate it until iteration starts. This would eliminate the time penalty of hydration when counting a collection, but may still cause large memory consumption when counting a large collection.