I have the following LINQ statement, and I'm finding that it's not running as quickly as I'd like. Are there other variations that run faster, or is there another way to do it that is faster?
var products = session.Products.Where(x => x.Supplier.Address.State == "HI").ToList();
What you didn't state is that this was in a blog post for a specific LINQ provider. Let's put it in context:
And now query it:
using(var session=new Session()){
var products = session.Products.Where(x => x.Supplier.Address.State == "HI")
.ToList();
}
… and it works :). This is what’s called a “Deep Graph” query in the ObjectDatabase world and usually spells trouble for performance. To be honest I haven’t pegged this query yet over multiple records – but from what I’ve read this is normal for Mongo and it supports it quite well.
It's not the call to ToList which "usually spells trouble for performance" - it's the fact that you're doing a "deep graph query" in an object database. Yes, you're then fetching all the results into memory, but it's the nature of the store which is the cause for concern here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With