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

Path fusion rewrite to mark the root of any constant path subtree as constant

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization

      The motivation is related to SERVER-79367. Consider the following path:

      Drop "a" * Field "a" p

      Where p is some arbitrary path. If we try to convert to MakeObjSpec, we will fail to translate the PathComposeM because there is no way to encode "pass Nothing to p and set field 'a' to the output". This sort of path comes up when we have consecutive projection stages where we exclude a path and then set that path to something else.

      Because we fail to translate, we will fallback to lowering, which is provably slow. We can do better. Note the following:

      Drop "a" = Field "a" Const Nothing
      =>
      Field "a" Const Nothing * Field "a" p = Field "a" (Const Nothing * p) = Field "a" Const (p | Nothing)

      If we can perform this rewrite, e.g. by setting the child of PathConst to (Const Nothing * p), then we can definitely translate a path of the form Field "a" Const c to MakeObjSpec/ get a better plan.

       

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            alya.berciu@mongodb.com Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: