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

Potentially unexpected scans with compound indexes when some fields are multikey

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.2
    • Component/s: Querying
    • None
    • ALL

      Lets say you are querying for { a:{ $gt:10, $lt:20 } }

      and you have an index on a, b

      If b is multikey, the query optimizer will scan a much wider range of index and it will have to scan the objects to complete query evaluation. This is because the optimizer doesn't know if all the values of a are scalar; if they are not a document like { _id:2, { a:[ 5, 25 ] } } would match the query.

      This makes the advice that an index on a is not needed if you have an index on a, b incorrect and makes performance optimization confusing.

            Assignee:
            hari.khalsa@10gen.com hari.khalsa@10gen.com
            Reporter:
            max@10gen.com Max Schireson
            Votes:
            13 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: