SERVER-138066ClosedFixed

$shardedDataDistribution is slow when the chunk count is large

The current {{$shardedDataDistribution}} performs a {{$lookup}} operation on {{config.chunks}} to determine which shards contain chunks for each sharded collection. The observed execution plan used the \{uuid: 1, min: 1} index instead of the existing \{uuid: 1, shard: 1, min: 1} index. Therefore, it examines every chunk document matching the collection's UUID to collect the distinct shards ids. Consequently, the work grows with the total number of chunks across the collections being process

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-rc10259.0.9
Components
Server components related to this issue

No components specified.

Labels
Tags and classification

No labels assigned.