MongoDB Tricks: count() operation
From a ☞ thread on MongoDB group:
count()without a query is an instant O(1) operation.
count({})with a query is an O(n) operation. Having an index on the query field will speed up the process, but it will still require counting each object. I would suggest keeping real-time counters using$incwhere possible to avoid large counts.
There’s also ☞ JIRA ticket marked as fixed in MongoDB 1.7.
Original title and link: MongoDB Tricks: count() operation (NoSQL databases © myNoSQL)