Currently, when we run db.collection.stats() on a sharded cluster, it appears that the scale factor gets "passed down" to calculate each shards' index size, and then those individual sizes get summed up to give the totalIndexSize. For example, as we can observe below,
1) The "totalIndexSize" = 0 = 0 + 0 + 0, which is the sum of the totalIndexSize from each shard.
2) The "totalIndexSize" = 73838592 = 49078272 + 16392192 + 8368128, which is the sum of the totalIndexSize from each shard.
Therefore, the scale factor gets "passed down" to calculate each shards' index size, and then those individual sizes get summed up to give the totalIndexSize.
However, instead of calculating the totalIndexSize this way, it would be more accurate if the totalIndexSize returned was scaled/rounded after summing the size from the individual shards. For example, if there are 3 shards with each shard having an index sized 0.99 GB, then the scale 1024*1024*1024 would round each shard's index size to 0, and so the totalIndexSize reported will be 0 as well. However, if the individual shards' index sizes were to be added first (to yield 2.997 GB) and then the scaling factor was applied to the totalIndexSize, then the totalIndexSize reported will be 2GB (and not 0 GB).
Therefore, instead of applying the scaling factor to the index sizes retrieved for each shards, this improvement request is to scale/round the totalIndexSize only after summing the index sizes from the individual shards.