-
Type:
Improvement
-
Resolution: Done
-
Priority:
Minor - P4
-
Affects Version/s: 1.8.3
-
Component/s: LINQ
-
None
Presently any query of the form:
coll.Where(c => c.Array.Any(a => a.value == val))
maps to the database as something like:
db.Coll.find({ "Array" : { "$elemMatch" :
{"Value" : val }} } )
A faster query which is entirely acheivable in the C# driver is:
db.Coll.find(
{ "Array.Value" : val })
For example, this query:
books.Where(b => b.Ratings.Any(r => r.Value >= 0))
becomes:
db.Book.find({ "Ratings" : { "$elemMatch" : {"Value" :
{ "$gte" : 0 }} } } )
It should be
db.Book.find({ "Ratings.Value":
{ "$gte" : 0 }} )