Query Optimizer Index Scans when first predicate is unbounded.

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.6.0
    • Component/s: Querying
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Imagine you have fields A & B and a compound index defined as

       { A :1, B:1} 

      Now imagine a query

       find( { B : value }).sort(A) 

      In 2.4 it appears we would jump to all values of A and within each subset of A skip to entries where B="value" in the index. Leading to a smaller nscannedObjects() value in the query plan.

      As of 2.6 it appears indexed plans where the first field in the index is unconstrained are not considered. Which means we end up not using plans in 2.6 that would sometimes get used in 2.4

      In this particular case, we end up essentially doing a full index scan. Which depending on data distribution, will most likely be slower than in 2.4.

            Assignee:
            James Wahlin
            Reporter:
            Osmar Olivo (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: