[SERVER-61447] Investigate skipping argument expression evaluation in $group for $first/firstN once accumulator has necessary values Created: 12/Nov/21  Updated: 29/Oct/23  Resolved: 13/Jan/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.3.0

Type: Task Priority: Major - P3
Reporter: Mihai Andrei Assignee: Mihai Andrei
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: QE 2021-12-13, QE 2021-12-27, QE 2022-01-10, QE 2022-01-24
Participants:

 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).



 Comments   
Comment by Githook User [ 12/Jan/22 ]

Author:

{'name': 'Mihai Andrei', 'email': 'mihai.andrei@10gen.com', 'username': 'mtandrei'}

Message: SERVER-61447 Skip expression evaluation when AccumulatorFirst/AccumulatorFirstN are full in $group and $bucketAuto
Branch: master
https://github.com/mongodb/mongo/commit/36d096e95aa193d08eb934987d6617b65cc1eadf

Generated at Thu Feb 08 05:52:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.