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

Strange geolocation query slowness

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.6.4, 1.7.2
    • Affects Version/s: 1.5.4
    • Component/s: Geo
    • Labels:
      None
    • Environment:
      Linux
    • Linux

      I'm noticing huge disparities between some geolocation queries. The queries don't seem all that different, yet there is a huge difference in time taken to complete them--as in, some reliably finish in under a second, while others reliably take seconds or more. See, for instance, this session:

      MongoDB shell version: 1.5.5-pre-

      connecting to: hermes

      > db.nodes.find({ loc: { $within: { $box: [

      { lat: 30.29714, lon: -97.73608 }

      <ithin: { $box: [

      { lat: 30.29714, lon: -97.73608 }

      ,

      { lat: 30.29914, lon: -9 <.29714, lon: -97.73608 }

      ,

      { lat: 30.29914, lon: -97 .73408000000001 }

      ] } } }

      <

      { lat: 30.29914, lon: -97.73408000000001 }

      ] } } }) .explain()

      { "cursor" : "GeoBrowse-box", "nscanned" : 5, "nscannedObjects" : 5, "n" : 5, "millis" : 5021, "indexBounds" : [ ] }

      >

      >
      <29914, lon: -97.73408000000001 } ] } } }).explain()

      { "cursor" : "GeoBrowse-box", "nscanned" : 5, "nscannedObjects" : 5, "n" : 5, "millis" : 5434, "indexBounds" : [ ] }

      >
      <29914, lon: -97.73408000000001 } ] } } }).explain()

      { "cursor" : "GeoBrowse-box", "nscanned" : 5, "nscannedObjects" : 5, "n" : 5, "millis" : 5516, "indexBounds" : [ ] }

      > db.nodes.find({ loc: { $within: { $box: [

      { lat: 30.29664, lon: -97.7364 }

      ,
      <ithin: { $box: [

      { lat: 30.29664, lon: -97.7364 }

      ,

      { lat: 30.29864, lon: -97 <.29664, lon: -97.7364 }

      ,

      { lat: 30.29864, lon: -97. 73439999999999 }

      ] } } })

      < lat: 30.29864, lon: -97.73439999999999 } ] } } }). explain()

      { "cursor" : "GeoBrowse-box", "nscanned" : 6, "nscannedObjects" : 6, "n" : 6, "millis" : 562, "indexBounds" : [ ] }

      >
      <29864, lon: -97.73439999999999 } ] } } }).explain()

      { "cursor" : "GeoBrowse-box", "nscanned" : 6, "nscannedObjects" : 6, "n" : 6, "millis" : 559, "indexBounds" : [ ] }

      >
      <29864, lon: -97.73439999999999 } ] } } }).explain()

      { "cursor" : "GeoBrowse-box", "nscanned" : 6, "nscannedObjects" : 6, "n" : 6, "millis" : 563, "indexBounds" : [ ] }

      It appears that the second query scans and returns more objects, yet it takes a tenth the amount of time. Note that the first query takes ten times longer to return, but this is actually short. I've had queries that took upwards of 30 seconds to return similar results.

      None of these areas are sparsely populated with points, so I don't think that the issue is that the query distances need to be limited.

      You can find my dataset here: http://dl.dropbox.com/u/147071/dump.tar.bz2 It's 293M, and I apologize for that, but I don't know what specific aspects of my data may be causing this disparity in search times. Dropbox says that the file will finish uploading in an hour or so.

      Also, because the above transcript didn't paste in such that the queries are cut-and-paste-friendly, here are the two that I am trying, slow query first:

      db.nodes.find({ loc: { $within: { $box: [

      { lat: 30.29714, lon: -97.73608 }

      ,

      { lat: 30.29914, lon: -97.73408000000001 }

      ] } } }).explain()

      db.nodes.find({ loc: { $within: { $box: [

      { lat: 30.29664, lon: -97.7364 }

      ,

      { lat: 30.29864, lon: -97.73439999999999 }

      ] } } }).explain()

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            nolan Nolan Darilek
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: