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
With this approach mongoid will fire only one count query
The previous version caused 3 query:
1. collection.empty? => load an item to ensure there are items in the collection
2. collection.first ... => again load an item to be sure about we querying mongo
3. collection.count(true) => actual count command
0 commit comments