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

2d index no longer supports exact match

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.3
    • Component/s: Geo
    • None

      I'm managing a 10k x 10k planar grid, in which I wish to use a 2d index for distance calculations/queries. For that, each entry in this grid is a document with a 'loc' field with its coordinates. Such coordinates, therefore, are integers between 0 and 9999 inclusive. The index creation needs then to specify a 'min' and a 'max'.

      In v2.4, queries on exact coordinates work as expected, returning almost immediately, with nscanned:1:

      db.loc_test.find({loc:[23,24]}).explain()
      {
              "cursor" : "GeoBrowse-circle",
              "isMultiKey" : false,
              "n" : 1,
              "nscannedObjects" : 1,
              "nscanned" : 1,
              "nscannedObjectsAllPlans" : 1,
              "nscannedAllPlans" : 1,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
      ...
      

      After upgrading to v2.6.3, the same query performs a full scan:

      db.loc_test.find({loc:[23,24]}).explain()
      {
              "cursor" : "BasicCursor",
              "isMultiKey" : false,
              "n" : 1,
              "nscannedObjects" : 6250000,
              "nscanned" : 6250000,
              "nscannedObjectsAllPlans" : 6250000,
              "nscannedAllPlans" : 6250000,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 49010,
              "nChunkSkips" : 0,
              "millis" : 32279,
      

      I am not sure 2d indexes on such ranges are actually allowed...

            Assignee:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Reporter:
            pep.martinez Pep Martinez
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: