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

Push top-level field extraction into 'scan' in Bonsai-generated SBE plans

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 7.0.0-rc7
    • Component/s: None
    • Labels:
      None
    • Query Optimization

      The extraction of multiple top level fields can be represented in an SBE plan either as a series of getField() calls, or as a single scan over several slots.

      Here is an example of the former (outputted by Bonsai):

      [5] filter {shardFilter(s5, makeBsonObj(MakeObjSpec(drop, [], ["a", "b", "c"]), Nothing, s2, s3, s4))} 
      [4] project [s4 = getField(s1, "c")] 
      [3] project [s3 = getField(s1, "b")] 
      [2] project [s2 = getField(s1, "a")] 
      [1] scan s1 none none none none none none none lowPriority [] @"<collUUID>" true false  

      And of the latter (outputted by Stage Builders):

      filter {shardFilter(s5, makeBsonObj(MakeObjSpec(drop, [], ["a", "b", "c"]), Nothing, s2, s3, s4))} 
      scan [s2 = a, s3 = b, s4 = c] 

      The latter is far more efficient, and should be the behavior of Bonsai-generated plans as part of CQF.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            richard.hausman@mongodb.com Richard Hausman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: