I wonder is it possible to add coalescing optimization to a sequence of $group and $limit in aggregation pipeline?
For example, I have a pipeline like this:
My goal is to get small subset of $ti ("thread id") that have latest $ct ("conversation timestamp"). Execution time for this request is prohibitively high and I guess it's because $group stage process all input documents and apply limit afterwards.
It seems that incorporating $limit into $group processing would benefit this query by avoiding computations that will be thrown away in any case.