Serene Taleb-Agha Serene Taleb-Agha - 20 days ago 6
C# Question

Performance when using Filter.Where using the MongoDB C# driver

Say you have the following line of code:

var filter = Builders<BsonDocument>.Filter.Where(t => t.id == myId);
var result = collection.Find(filter).ToList();


Does the filter builder translate the lambda to a literal $where clause or does it optimize it to use the $eq clause? $where has slow performance so I don't want to use it if there's no translation.

This is a simple example but we have other queries in our code that are lengthier but would easily translate to non-$where queries.

Answer

I have no idea. I will look into this tonight and come back to you.

Comments