[SERVER-19039] geoNear scans the same index cells multiple times, slowing down queries with many search intervals Created: 18/Jun/15  Updated: 05/Feb/16  Resolved: 20/Jul/15

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: None
Fix Version/s: 3.1.6

Type: Improvement Priority: Major - P3
Reporter: Brandon Zhang Assignee: Brandon Zhang
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-18056 2d nearSphere performance regression Closed
Duplicate
is duplicated by SERVER-13568 Near search using find() with 2DSpher... Closed
Tested
Backwards Compatibility: Fully Compatible
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 20/Jul/15 ]

Author:

{u'name': u'Brandon Zhang', u'email': u'brandon.zhang@mongodb.com'}

Message: SERVER-19039 Buffer fetched documents in geoNear
Branch: master
https://github.com/mongodb/mongo/commit/1de0a646d1c373e8a694d2a26c3f5ebb10137f14

Generated at Thu Feb 08 03:49:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.