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

When choosing multikey index bounds, never choose a superset if a subset is available

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.4
    • Component/s: Querying
    • Query Optimization

      For queries with multiple predicates over a multikey field, you can't intersect the index bounds. Suppose there is a multikey index on field 'a'. The following query

      db.t.find({a: {$lte: 0, $gte: 1}});
      

      would have empty index bounds if 'a' were not a multikey field. Since it is multikey, however, we either use bounds

      [-Infinity, 0]
      

      or

      [1, Infinity]
      

      Which bounds to use is chosen arbitrarily. As an optimization, we could make sure that we always choose the smallest interval over which to perform the index scan. For instance, for the query

      db.t.find({a: {$gt: 4, $gte: 5}});
      

      we would choose

      [5, Infinity]
      

      rather than

      (4, Infinity]
      

      because the former is a subset of the latter.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            11 Vote for this issue
            Watchers:
            23 Start watching this issue

              Created:
              Updated: