-
Type: Question
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
QO 2021-10-18, QO 2021-11-01, QO 2021-11-15, QO 2021-11-29, QO 2021-12-13, QO 2021-12-27, QO 2022-01-10, QO 2022-01-24, QO 2022-02-07, QO 2022-02-21, QO 2022-03-07, QO 2022-03-21, QO 2022-04-04, QO 2022-04-18, QO 2022-05-02, QO 2022-05-16, QO 2022-05-30, QO 2022-06-13, QO 2022-06-27, QO 2022-07-11
In $group, the $push and $addToSet accumulators have their own memory limits (as of SERVER-44174). Should we do something similar when they are used in $setWindowFields?
AccumulatorPush::processInternal does the check here:
https://github.com/mongodb/mongo/blob/a0198789a90fb099a252a441849ac0678d3862a7/src/mongo/db/pipeline/accumulator_push.cpp#L54
But WindowFunctionPush::add() does not: https://github.com/mongodb/mongo/blob/a0198789a90fb099a252a441849ac0678d3862a7/src/mongo/db/pipeline/window_function/window_function_push.h#L51
$group already tracks the total memory usage, to decide when to spill to disk. I think this extra limit was added because $push and $addToSet don't really benefit from spilling (if an intermediate result is too big, so will the final result).
See also SERVER-43944, which asks for a more general solution, for all operators.