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

geoNear scans the same index cells multiple times, slowing down queries with many search intervals

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.6
    • Affects Version/s: None
    • Component/s: Geo
    • None
    • Fully Compatible

      geoNear generates search intervals intended to contain between 300 and 600 documents. The minimum distance of each search interval is the same as the maximum distance of the previous one.
      In the current implementation, it will create an approximate covering of the search interval using index cells. This covering may contain index cells that were already scanned in the previous search interval, resulting in the same index cells and documents being checked more than once. For dense data, these search intervals will be very thin, resulting in an inaccurate covering that will likely contain many cells that were already in coverings of previous search intervals.

      Possible solution:
      Maintain a union of all of the cells that have been contained in previous coverings. When generating the covering for a new search interval, only cover the region that does not intersect with the union.
      This solution will improve performance for queries that require many search intervals, but will slightly slow performance for queries that only require one search interval because it will fetch all the documents in the covering regardless of whether they are in the search interval.

            Assignee:
            brandon.zhang Brandon Zhang
            Reporter:
            brandon.zhang Brandon Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: