Hello All,
I've been looking at a problem Mongo Query and was attempting to specify multiple indexes using the hint(). This lead me onto the following...
So I guess this still isn't possible but I'd like a clarification is anyone know...
I have a query with a couple of or clauses that would ideally use a different, specific index each. One of them sometimes doesn't, if I specify the index using hint, i.e.
db.collection.find( { "$or": [ { "foo": 1}, { "bar": 2 } ] }).hint( "index_on_bar");
Would this restrict the first clause to that index only? In my case that index is not at all useful for the first or clause so I think it's causing a collection scan.
I have attempted something like this..
db.collection.find( { "$or": [ { "foo": 1}, { "bar": 2 } ] }).hint( "index_on_foo", "index_on_bar");
The syntax is accepted but the query doesn;t complete.
Cheers,
Rhys