SERVER-138967Backlog

queryStats CBR nDocsSampled inaccurate for $lookup etc.

Currently the counter is not [additive|https://github.com/mongodb/mongo/blob/d48ca0a141adc807e22d47ee8cfd9e3d0ecb2bbb/src/mongo/db/query/plan_ranking/cbr_plan_ranking.cpp#L164-L165] so queries which plan more than once (eg. $lookup) under-report. Found by Claude Opus 5.5.

Affected Versions
Versions known to exhibit this issue

No affected versions recorded.

Fixed Versions
Versions that include the fix

No fix available yet.

Components
Server components related to this issue

No components specified.

Labels
Tags and classification
CBRfound-by-ai