SERVER-134077ClosedFixed

Query stats supplemental metrics are only recorded when the initial batch exhausts the cursor

Supplemental query stats metrics (e.g. the JoinOptimization section) only appear in the recorded query stats entry when the query's initial batch exhausts the cursor. With the default 101-doc batch plus getMores, the entry has no {{supplementalMetrics}} at all, even though the query ran join optimization. Repro: in {{{}jstests/noPassthrough/query/joins/query_stats_join_optimization_metrics.js{}}}, remove the {{{batchSize: 100000}}} option from any aggregate,  {{stats[0].metrics.supplementalMe

Affected Versions
Versions known to exhibit this issue

No affected versions recorded.

Fixed Versions
Versions that include the fix
9.1.0-rc09.1.0-rc10249.0.48.3.16
Components
Server components related to this issue

No components specified.

Labels
Tags and classification
bkpdino-query-statsgreenerbuild