-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Index Maintenance, Querying
-
Minor Change
-
ALL
-
v4.2, v4.0
-
Query 2019-08-12
-
49
The document {a: MinKey} should not match the query {a: { $gt: MinKey }}. However when there is an index present, MinKey is considered in the bounds for the index scan.
> db.test_min_max.find() { "_id" : "a_max_key", "a" : { "$maxKey" : 1 } } { "_id" : "a_min_key", "a" : { "$minKey" : 1 } } { "_id" : "a_null", "a" : null } { "_id" : "a_number", "a" : 4 } { "_id" : "a_subobject", "a" : { "b" : "hi" } } { "_id" : "a_undefined", "a" : undefined } { "_id" : "a_string", "a" : "hello" } > db.test_min_max.find({a: {$gt: MinKey}}) { "_id" : "a_min_key", "a" : { "$minKey" : 1 } } . // THIS IS WRONG { "_id" : "a_undefined", "a" : undefined } { "_id" : "a_null", "a" : null } { "_id" : "a_number", "a" : 4 } { "_id" : "a_string", "a" : "hello" } { "_id" : "a_subobject", "a" : { "b" : "hi" } } { "_id" : "a_max_key", "a" : { "$maxKey" : 1 } } > db.test_min_max.find({a: {$gt: MinKey}}).explain() { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "test.test_min_max", "indexFilterSet" : false, "parsedQuery" : { "a" : { "$gt" : { "$minKey" : 1 } } }, "winningPlan" : { "stage" : "FETCH", "inputStage" : { "stage" : "IXSCAN", "keyPattern" : { "a" : 4 }, "indexName" : "a_4", "isMultiKey" : false, "multiKeyPaths" : { "a" : [ ] }, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : 2, "direction" : "forward", "indexBounds" : { "a" : [ "[MinKey, MaxKey]" . // THIS IS WRONG ] } } }, "rejectedPlans" : [ ] }, "serverInfo" : { "host" : "franklinia", "port" : 27017, "version" : "0.0.0", "gitVersion" : "unknown" }, "ok" : 1 }
- is related to
-
SERVER-47042 Disable min_max_key.js test prior to 4.4
- Closed