diff options
Diffstat (limited to 'src/mongo/db/query/planner_ixselect.h')
-rw-r--r-- | src/mongo/db/query/planner_ixselect.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/query/planner_ixselect.h b/src/mongo/db/query/planner_ixselect.h index 1b7fed5eed0..5bc5f152632 100644 --- a/src/mongo/db/query/planner_ixselect.h +++ b/src/mongo/db/query/planner_ixselect.h @@ -153,6 +153,20 @@ public: */ static bool logicalNodeMayBeSupportedByAnIndex(const MatchExpression* queryExpr); + /** + * We can use an index for this special case: {$not:{$in:[null, []]}}. Return true if this is + * the expression (modulo in-list ordering) and it doesn't contain any regexes. + * + * Why is this case special? An equality expression for "null" will match both documents with a + * literal null for the specified key, and those where the key is not present. An equality + * expression for "[]" (which is stored as "undefined" in the index) will match documents with + * an empty array or an array with an empty array element. If we negate either of this bounds in + * isolation, we may produce incomplete results wrt the other expression. If we negate the + * composition of the two, we can properly return complete results excluding both null and empty + * array values. + */ + static bool canUseIndexForNin(const InMatchExpression* ime); + private: /** * Used to keep track of if any $elemMatch predicates were encountered when walking a |