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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Backlog
    • Major - P3
    • Resolution: Unresolved
    • 2.5.4
    • None
    • Querying
    • Query Optimization

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              backlog-query-optimization Backlog - Query Optimization
              david.storch@mongodb.com David Storch
              Votes:
              11 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

                Created:
                Updated: