SERVER-125570ClosedFixed
Pushdown $match on keyHash into $queryStats stage to avoid full store scan
h2. Overview The {{$queryStats}} aggregation stage currently performs a full linear scan of the in-memory query stats store on every invocation, regardless of any downstream {{$match}} predicates. Pipelines of the form re-serialize the representative shape for every entry in the store and then discard most of them via the filter — wasted CPU proportional to store size, not result size. h2. Background Production clusters with many distinct query shapes have been observed running this pi