Skip to content

Instantly share code, notes, and snippets.

@tairov
Created August 15, 2013 08:53
Show Gist options
  • Save tairov/6239351 to your computer and use it in GitHub Desktop.
Save tairov/6239351 to your computer and use it in GitHub Desktop.
mongodb, get jumbo chunks size
var ns = "mydb.mycollection" //the full namespace of the collection
var key = { "su" : 1, "sd" : 1 } //the shard key of the collection
db.getSiblingDB("config").chunks.find({ns : ns}).forEach(function(chunk) {
var ds = db.getSiblingDB(ns.split(".")[0]).runCommand({datasize:chunk.ns,keyPattern:key,min:chunk.min,max:chunk.max});
print("Chunk: "+chunk._id +" has a size of "+ds.size+", and includes "+ds.numObjects+" objects (took "+ds.millis+"ms)")
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment