Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
MongoDB shell version: 2.2.0 connecting to: test mongos> use mydb switched to db mydb mongos> for(var i = 0;i < 200000;i++) { ... var cats = {}; ... for(var j = 0; j< Math.random() * 10; j++) { ... cats[Math.floor(Math.random() * 10)] = Math.random(); ... } ... db.mycollection.insert({partnerId:j,id:i,categories:cats}); ... } mongos> db.mycollection.ensureIndex({partnerId:1,id:1}) mongos> sh.enableSharding("mydb") {"ok" : 1 } mongos> sh.shardCollection("mydb.mycollection",{partnerId:1,id:1}) {"collectionsharded" : "mydb.mycollection", "ok" : 1 } mongos> sh.status() --- Sharding Status --- sharding version: {"_id" : 1, "version" : 3 } shards: {"_id" : "shard2", "host" : "shard2/localhost:18003,localhost:18004,localhost:18005" } databases: {"_id" : "admin", "partitioned" : false, "primary" : "config" } {"_id" : "test", "partitioned" : true, "primary" : "shard2" } {"_id" : "mydb", "partitioned" : true, "primary" : "shard2" } mydb.mycollection chunks: shard2 1 {"partnerId" : {$minKey : 1 }, "id" : {$minKey : 1 } } -->> {"partnerId" : {$maxKey : 1 }, "id" : {$maxKey : 1 } } on : shard2 Timestamp(1000, 0) mongos> var ns = "mydb.mycollection" //the full namespace of the collection mongos> var key = {partnerId : 1, id : 1} //the shard key of the collection mongos> mongos> 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)") ... } ... ) Chunk: mydb.mycollection-partnerId_MinKeyid_MinKey has a size of 21082696, and includes 200000 objects (took 182ms) mongos> mongos> mongos> mongos> mongos> mongos> for(x=0;x<100000;x++){db.mycollection.insert({partnerId:x,id:x})} mongos> sh.status() --- Sharding Status --- sharding version: {"_id" : 1, "version" : 3 } shards: {"_id" : "shard2", "host" : "shard2/localhost:18003,localhost:18004,localhost:18005" } databases: {"_id" : "admin", "partitioned" : false, "primary" : "config" } {"_id" : "test", "partitioned" : true, "primary" : "shard2" } {"_id" : "mydb", "partitioned" : true, "primary" : "shard2" } mydb.mycollection chunks: shard2 4 {"partnerId" : {$minKey : 1 }, "id" : {$minKey : 1 } } -->> {"partnerId" : 0, "id" : 0 } on : shard2 Timestamp(1000, 1) {"partnerId" : 0, "id" : 0 } -->> {"partnerId" : 3, "id" : 110484 } on : shard2 Timestamp(1000, 5) {"partnerId" : 3, "id" : 110484 } -->> {"partnerId" : 10, "id" : 196569 } on : shard2 Timestamp(1000, 6) {"partnerId" : 10, "id" : 196569 } -->> {"partnerId" : {$maxKey : 1 }, "id" : {$maxKey : 1 } } on : shard2 Timestamp(1000, 4) mongos> var ns = "mydb.mycollection" //the full namespace of the collection mongos> var key = {partnerId : 1, id : 1} //the shard key of the collection mongos> mongos> 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)") ... } ... ) Chunk: mydb.mycollection-partnerId_MinKeyid_MinKey has a size of 0, and includes 0 objects (took 0ms) Chunk: mydb.mycollection-partnerId_0.0id_0.0 has a size of 7367620, and includes 79892 objects (took 76ms) Chunk: mydb.mycollection-partnerId_3.0id_110484.0 has a size of 13715544, and includes 120118 objects (took 97ms) Chunk: mydb.mycollection-partnerId_10.0id_196569.0 has a size of 5599532, and includes 99990 objects (took 74ms) mongos>