[SERVER-61323] Optimize $geoNear minDistance bounds on time-series metrics Created: 08/Nov/21  Updated: 06/Dec/22  Resolved: 19/Nov/21

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

Type: Improvement Priority: Major - P3
Reporter: David Percy Assignee: Backlog - Query Optimization
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-58602 Rewrite $geoNear to $geoWithin + comp... Closed
Duplicate
duplicates SERVER-58602 Rewrite $geoNear to $geoWithin + comp... Closed
Related
Assigned Teams:
Query Optimization
Participants:

 Description   

After SERVER-58602, a $geoNear stage operating on time-series measurement field is implemented as separate stages for the filtering, projection, and sort. The 'maxDistance' argument becomes a $geoWithin predicate, which can generate index bounds when a 2d or 2dsphere index is available.

We could do something similar for 'minDistance'. A few ideas are:

  • For a spherical query, create an "inside-out" $geoWithin: center it around an antipodal point, with a radius of pi - minDistance.
  • For a flat query, create a negated $geoWithin. Use a slightly smaller radius, perhaps (minDistance * (1 - epsilon)), to avoid excluding points exactly minDistance from the query.
  • Introduce a new shape operator, similar to $center and $centerSphere but with a minDistance argument in addition to maxDistance.

Generated at Thu Feb 08 05:52:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.