summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/planner_ixselect.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/planner_ixselect.h')
-rw-r--r--src/mongo/db/query/planner_ixselect.h14
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 0bd1accd5bc..84f00d656da 100644
--- a/src/mongo/db/query/planner_ixselect.h
+++ b/src/mongo/db/query/planner_ixselect.h
@@ -158,6 +158,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