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

Optimize $size + ExpressionFieldPath

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Aggregation Framework
    • Labels:
      None

      Description

      Currently when evaluating something like {$size: '$a.b'} on a document like {a: [{b:1},{b:2}, ...]} we will first evaluate the ExpressionFieldPath which will produce an array of the values of b, then we ask for the size of that array. This is wasteful, and is even more wasteful if you consider '$a.b.c.d' where each level is an array of object since only the size of the a array matters in that case. (I'm not arguing that these semantics are good, but that is what we do today). Instead we should have an ExpressionSizeOfFieldPath that just returns the size of the top-level array that ExpressionFieldPath would create, but without making any new arrays.

      I have a profile where over 20% of the time is spent in the unnecessary ExpressionFieldPath for the simple '$a.b' case. I assume it would be even worse for '$a.b.c.d.

        Attachments

          Activity

            People

            Assignee:
            backlog-query-execution Backlog - Query Execution
            Reporter:
            redbeard0531 Mathias Stearn
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: