The general counting request will execute
int count = collection.Find(filter).Count();
Now that all the records are loaded according to the filter, so let's point out that I have 1 million records, and of these 0.5 million correspond to my filter, so I will have a collection filled with just 0.5 documents. This is good enough if you want documents, but what if you just want to know the bill and do not need documents, for the sake of memory.
Can i do something like this
int count = collection.Find(filter).SetLimit(1).Count();
This gives me the same meaning as the first expression, but I hope that the memory will not be used as the first expression, help me find out the correct way to find the "account" without loading all the documents. Thanks.
source
share