Hi all.
If I had the following sample data:
[
{
name: “John”,
city: “London”
},
{
name: “Jason”,
city: “London”
}
]
And ran the following query:
db.collection.find({ $or: [ { name: “John” }, { city: “London” } ] })
Would the $or operator be able to scan both of the following indexes or would it just pick one, best-matching index?
{ name: 1 }
{ city: 1 }
Would I be better off using
{ city: 1, name: 1 }
For maximum efficiency here?
Thanks in advance.