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

Investigate skipping argument expression evaluation in $group for $first/firstN once accumulator has necessary values

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 5.3.0
    • None
    • None
    • None
    • Fully Compatible
    • QE 2021-12-13, QE 2021-12-27, QE 2022-01-10, QE 2022-01-24

    Description

      One idea to improve the performance of a $sort + $first/$firstN pipeline is to skip evaluating the Accumulator 'argument' expression for $first/$firstN if a given AccumulatorState doesn't need any more input (i.e. when we have 1 or 'n' values, respectively). This could potentially save time if it's expensive to evaluate the argument expression. (note that we can never short circuit $group entirely: as long as we have input documents, there's a chance that we can start a new group).

      This task should see whether this produces any performance benefits for $first/firstN groups (that is, we need to figure out first whether this yields performance improvements; because you still have to inspect every document that comes into group no matter what, it might be the case that skipping expression evaluation doesn't save so much time).

      Attachments

        Activity

          People

            mihai.andrei@mongodb.com Mihai Andrei
            mihai.andrei@mongodb.com Mihai Andrei
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: