title: How to remove chunks from mongodb shard
body: <p>I have a collection where the sharding key is UUID (hexidecimal string). The collection is huge: 812 millions of documents, about 9600 chunks on 2 shards. For some reason I initially stored documents which instead of UUID had integer in sharding key field. Later I deleted them completely, and now all of my documents are sharded by UUID. But I am now facing a problem with chunk distribution. While I had documents with integer instead of UUID, balancer created about 2700 chunks for these documents, and left all of them on one shard. When I deleted all these documents, chunks were not deleted, they stayed empty and they will always be empty because I only use UUID now. Since balancer distrubutes chunks relying on chunk count per shard, not document count or size, one of my shards takes 3 times more disk space than another:</p>
  
  <pre><code>--- Sharding Status ---
  db.click chunks:
      set1    4863
      set2    4784    // 2717 of them are empty
  
  set1&gt; db.click.count()
  191488373
  
  set2&gt; db.click.count()
  621237120
  </code></pre>
  
  <p>The sad thing here is mongodb does not provide commands to remove or merge chunks manually. 
  My main question is, whould anything of this work to get rid of empty chunks:</p>
  
  <ol>
  <li><p>Stop the balancer. Connect to each config server, remove from <code>config.chunks</code> ranges of empty chunks and also fix <code>minKey</code> slice to end at beginning of first non-empty chunk. Start the balancer.
  Seems risky, but as far as I see, <code>config.chunks</code> is the only place where chunk information is stored.</p></li>
  <li><p>Stop the balancer. Start a new mongod instance and connect it as a 3rd shard. Manually move all empty chunks to this new shard, then shut it down forever. Start the balancer.
  Not sure, but as long as I dont use integer values in sharding key again, all queries should run fine.</p></li>
  </ol>