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

Unable to force predicate evaluation order with new query framework

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Backwards Compatibility:
      Minor Change

      Description

      In version 2.4 and before, predicate order was significant to the query optimizer. Thus if selectivity of a query predicate was known, it could influence the planner.

      Now, query plans are normalized into a generic query execution tree and re-ordered, so predicate evaluation order can be "surprising" based on the sort order of the actual data being queried for. There is no way to override this behavior because in both cases, the optimizer chooses the correct "plan" but can't choose the correct predicate to evaluate first.

      Attaching a test which if run in 2.4 and then 2.5.5 shows the change in behavior. One example uses a hash_merge of 3 $and predicates on a single multi-key index, one with a very low cardinality.

      The second example shows a 2 predicate $and query where the optimizer chooses the wrong query predicate.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: