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

More flexible query containment for $geoWithin

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • Query Optimization 2021-07-26, Query Optimization 2021-08-09
    • 127

      When considering whether a $geoWithin partial index can be used to satisfy a query, currently we treat the $geoWithin opaquely, so only queries that explicitly mention that region can use the index. For example,

      coll.createIndex({loc: '2dsphere'}, {partialFilterExpression: {loc: {$geoWithin: ... usa ... }}});
      
      coll.find({loc: {$geoWithin: ... usa ... }});  // indexed
      
      coll.find({$and: [                             // indexed
        {loc: {$geoWithin: ... usa ... }},  
        {loc: {$geoWithin: ... nyc ... }},
      ]});
      
      coll.find({loc: {$geoWithin: ... nyc ... }});  // not indexed
      

      The third query should be indexed, because nyc is geometrically contained in usa.

            Assignee:
            maddie.zechar@mongodb.com Maddie Zechar
            Reporter:
            david.percy@mongodb.com David Percy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: