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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 2.5.4
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Labels:

      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

              • Votes:
                12 Vote for this issue
                Watchers:
                20 Start watching this issue

                Dates

                • Created:
                  Updated: