title: Know real chunk sizes in mongodb
body: <p>I am trying to find the size of all chunks in one of my sharding collection.</p>
  
  <p>I'd like to know the <strong>real</strong>  size, not the hint given to the mongos as a setting which I know I can find with :</p>
  
  <pre><code>use config
  db.settings.find({_id : "chunksize"})
  </code></pre>
  
  <p>I have tried several solutions but the fact that <em>count</em> operation is very slow so this is not easy.
  Do you know a solution ? (shell, csharp, python, ruby, bash, I don't care)</p>
  
  <p>For now I have tested the following :</p>
  
  <pre><code>db.getSisterDB("config").chunks.find({ns : "mydb.mycollection"}).forEach(function(chunk) {
       db.getSisterDB("mydb").mycollection.find({},{_id : 0, partnerId , 1, id : 1}).min(chunk.min).max(chunk.max).count()
  })
  </code></pre>
  
  <p>but this is too slow, I am under the impression that it does not use the index on my shard key (which is on <code>{partnerId : 1, id : 1}</code>).</p>
  
  <p>I have also replaced <em>count</em> by <em>explain</em> without any luck. I have also replaced the <em>count</em> with a javascript <em>forEach</em> to manually count (trying to have a <em>indexOnly</em> query that would not hit disk).</p>
  
  <p>I am trying to find the real size because I have seen several chunks that are far above the chunksize given as a hint (2Gb instead of 64Mb).</p>