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

Query Optimizer Index Scans when first predicate is unbounded.

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

      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@mongodb.com James Wahlin
            Reporter:
            osmar.olivo Osmar Olivo
            Votes:
            1 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: