-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
Mongo does not use counted b-tree indexes: https://jira.mongodb.org/browse/SERVER-1752?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=147517#comment-147517
As such, Model.where(...).count can be very slow. When checking for the existence of some document set, there's no need to suffer through the slowness of count only to check > 0 (since, if one document is found, exists? should return true, no need to keep looking).
This pull request updates the exists? method to try to find a lone document instead of checking against the count.