DISTINCT_SCAN can be used with compound index when filter is on non-multikey field

XMLWordPrintableJSON

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

      If you have an index on a:1, b:1 and distinct command or agg equivalent

      db.foo.distinct("b", {a:1})
      

      we use DISTINCT_SCAN unless b is multikey - and it's not clear why - it doesn't need IXSCAN nor FETCH (which is what it shows using).

            Assignee:
            [DO NOT USE] Backlog - Query Optimization
            Reporter:
            Asya Kamsky
            Votes:
            2 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: