-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Index Maintenance, Querying
-
Environment:GNU/Linux Debian 6 x64,
-
Fully Compatible
-
ALL
Querying on an indexed field which contains Infinity and -Infinity does not produce expected results when using range predicates.
Note the upper bound on the second query is equal to max double value, which compares as less than infinity. If you do an equality search, it will use the index just fine.
Here's an example with explain output.
t = db.infinity t.drop() t.ensureIndex({number:1}) t.save({number: 3}); t.save({number: 4}); t.save({number: Infinity}); t.save({number: -Infinity}); t.find({"number": Infinity}).explain(); { "cursor" : "BtreeCursor number_1", "isMultiKey" : false, "n" : 1, "nscannedObjects" : 1, "nscanned" : 1, "nscannedObjectsAllPlans" : 1, "nscannedAllPlans" : 1, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { "number" : [ [ Infinity, Infinity ] ] }, "server" : "crucible-2.local:27017" } t.find({"number": {$gte: 2}}).explain()) { "cursor" : "BtreeCursor number_1", "isMultiKey" : false, "n" : 3, "nscannedObjects" : 3, "nscanned" : 3, "nscannedObjectsAllPlans" : 3, "nscannedAllPlans" : 3, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { "number" : [ [ 2, 1.7976931348623157e+308 ] ] }, "server" : "crucible-2.local:27017" }
- depends on
-
SERVER-11617 Sorting with value of Infinity causes assertion
- Closed
- is related to
-
SERVER-984 Invalid sorting of infinity and -infinity
- Closed