Why is MongoDB not using the correct index?

I have a MongoDB request that I am trying to optimize. I created an index that matches the fields in the query, but I cannot force the MongoDB query planner to use the index without an explicit one hint(), even if nscannedit’s millibetter for the intended version.

Here are the indexes, the query (with and without a hint) and a detailed explanation:

http://paste.roguecoders.com/p/4face5649612e840da04c5fea0491c9b.txt

One extra bit of information: this index is in a collection of a large number, in a set of replicas, so I built the index using a stand-alone method . Now it is present in all nodes.

(Originally published by MongoDB-User .)

+5
source share
1 answer

This is similar to regression in 2.4, which affects the SERVER-5063 fix when one of the values ​​in the {$ in: []} clause is null. I filed it as a new ticket https://jira.mongodb.org/browse/SERVER-9495 , which I hope will be streamlined and fixed soon.

Meanwhile, depending on why there are null values ​​(or the lack of a field?) Along with true / false, you have several options, some of which are related to modifying a query that changes data. I would not recommend lowering to 2.2 just for this, but it is also an opportunity.

+3
source

All Articles