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

$geoNear expands aggressively if the centroid is far from the dense data

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.0.2
    • Component/s: Geo
    • Query Integration

      I have a collection with 300,000 documents. In collection there is a 2dsphere index on 'geo' field.

      Here is a query I run:
      db.runCommand(

      { geoNear: "around_test", near: [59.6048899000000030, 36.2774393999999990], num: 500, spherical:true, query: null, }

      );

      Stats of this query are weird:
      stats:

      { "nscanned" : 103971, "objectsLoaded" : 80166, "avgDistance" : 0.1816846648955057, "maxDistance" : 0.1955302102158397, "time" : 1124 }

      In the query I limit results to 500 documents. But in stats I see that mongoDB reads 80166 (objectsLoaded) documents from disk and only then cuts it out.
      No need to read extra documents from disk if there is a limit on result length.

        1. around_test.7z
          3.69 MB
          Andrey Hohutkin

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            andrey.hohutkin@gmail.com Andrey Hohutkin
            Votes:
            0 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated: