Streaming $group with no accumulators

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

      Consider a query like {$group: {_id: ...}}. This $group accumulates nothing, and only produces each unique _id value, i.e. functions analogously to a distinct(), give or take some null semantics.

      This $group blocks before it can return a single result in the current implementation. However, we don't need the entire result set to return one value- in fact, we can return each $group _id as soon as we encounter it, and drop duplicates later (as long as we are keeping track). We should be able to return a new _id each time we encounter one.

      Note: this can be extended to any $group that doesn't compute any values using fields not included in the _id field! It is particularly relevant to a merging $group on mongos- see comments.

            Assignee:
            Unassigned
            Reporter:
            Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: