Running the following mongo query in RoboMongo (0.9.0-RC09) gives the correct number of documents (using the cursors count function), while iterating all documents does only return a small portion of documents:
var allDocuments = db.getCollection('mycollection').find({});
print(allDocuments.size()); // prints 170 000 -> correct
var count = 0;
allDocuments.forEach(function(doc) {
count++;
});
print(count); // 'randomly' prints values between 30 000 and 44 000
Do we need to specifically configure the query to return all documents?