ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0, 9.1.0-rc1026
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      From the benchmarks added in SERVER-137775.

      On refers to type inference flag being on.

      This is the time taken for a single canPathBeArray call on path 'x' in various pipelines.

      Benchmark Size Off On
      UnrelatedPredicates 10 / 100 / 1000 0.031 3.41 / 97.2 / 7950
      UnrelatedSubpathPredicates 10 / 100 / 1000 0.031 4.68 / 112 / 8218
      UnrelatedMatches 10 / 100 / 999 about 0.055 3.46 / 99.7 / 8014

      In all three cases, type inference evaluates all 999 or 1000 predicates even though only one predicate refers to x.

      Therefore, the On results are the cost of full type inference on the pipeline. Since we only run type inference for requested specific paths, we should not have to run type inference for the whole pipeline in these cases.

      Add an optional path filter to narrowType, with no filter by default. When narrowing from an Expression or MatchExpression, skip a PathMatchExpression when its path does not overlap the filter path.

      Also pass an option that says whether subfield or shape information is needed. When it is not needed, use NonLeafArrayBehaviour, LeafArrayBehaviour, and the current type of the target path to skip predicates that cannot further refine that type. This specifically improves UnrelatedSubpathPredicates.

      Examples of expressions that should not be evaluated for a type query on x:

      • {y: {$not: {$type: 'array'}}} does not refer to x, so it can be skipped.
      • {x.y: {$not: {$type: 'array'}}} can be skipped only when x is already known to be object | array. The predicate can only further remove array from x, but $type uses NonLeafArrayBehaviour::kTraverse, so it does not distinguish an array at x. If subfield information is not needed, skip the predicate entirely. This addresses UnrelatedSubpathPredicates.

            Assignee:
            Henri Nikku
            Reporter:
            Vesko Karaganev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: