NoSQL Benchmarks NoSQL use cases NoSQL Videos NoSQL Hybrid Solutions NoSQL Presentations Big Data Hadoop MapReduce Pig Hive Flume Oozie Sqoop HDFS ZooKeeper Cascading Cascalog BigTable Cassandra HBase Hypertable Couchbase CouchDB MongoDB OrientDB RavenDB Jackrabbit Terrastore Amazon DynamoDB Redis Riak Project Voldemort Tokyo Cabinet Kyoto Cabinet memcached Amazon SimpleDB Datomic MemcacheDB M/DB GT.M Amazon Dynamo Dynomite Mnesia Yahoo! PNUTS/Sherpa Neo4j InfoGrid Sones GraphDB InfiniteGraph AllegroGraph MarkLogic Clustrix CouchDB Case Studies MongoDB Case Studies NoSQL at Adobe NoSQL at Facebook NoSQL at Twitter



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 $inc where 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)