Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9277

Ranged index bounds do not permit retrieving Infinity or -Infinity

    XMLWordPrintableJSON

Details

    • Fully Compatible
    • ALL

    Description

      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"
      }

      Attachments

        Activity

          People

            benety.goh@mongodb.com Benety Goh
            aantonio Antonio Angelino
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: