I would like to asynchronously check for existence of a document in MongoDB using the MongoDB C#/.NET 2.0 Driver. I would like to query in such a way that performance maximization is considered.
For example, we started with
db.Collection.CountAsync(filter).Result;
which would not be good practice for performance, particularly if the filter can return numerous documents.
Something like
db.Collection.FindAsync(filter).Limit(1).Size();
would be better, but FindAsync does not exist.
Additionally, I've seen reference to "field selection" that seems would be good to apply as well to minimize the amount data in motion, but MongoDB is new to me so I don't yet know whether I would unknowingly be causing degraded performance.