Details
-
New Feature
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
None
-
Query Optimization
Description
When performing a $ne query such as:
db.getCollection('users').find({ 'name.middle': { '$ne': null } }).hint({'name.middle': 'hashed'}).explain()
|
I can see a full table scan is being performed before returning the result and the hash index is being ignored.
In our case, most of the records would have a null value and thus using the index to quickly reach out to the few relevant documents would have been much more efficient.
To workaround this, we had to resort to using a regular index on top of the more efficient/small hashed index.