Skip to content

Instantly share code, notes, and snippets.

@dbmurphy
Created October 10, 2014 18:21
Show Gist options
  • Save dbmurphy/3c1f9d3e608fab9f4de3 to your computer and use it in GitHub Desktop.
Save dbmurphy/3c1f9d3e608fab9f4de3 to your computer and use it in GitHub Desktop.
Chunk Collection Aggregations
mongos> chunksPerShard_Aggregation
{ "$group" : { "_id" : "$shard", "count" : { "$sum" : 1 } } }
mongos> chunksPerShardByNS_Aggregation
{
"$group" : {
"_id" : {
"shard" : "$shard",
"ns" : "$ns"
},
"count" : {
"$sum" : 1
}
}
}
mongos> db.chunks.aggregate(chunksPerShard_Aggregation);
{
"result" : [
{
"_id" : "d42f619034d73616dabde1ed098739c2",
"count" : 56
},
{
"_id" : "4fa0d97504185879b6e7524dda47d98b",
"count" : 56
},
{
"_id" : "d34ff18d819ea9dfeda0f638eae589f0",
"count" : 57
},
{
"_id" : "af6e8730844faa627625a6c3fa98f0fc",
"count" : 56
},
{
"_id" : "0e5302a229a01e20cf4e29ae4f352c54",
"count" : 4026
}
],
"ok" : 1
}
mongos> db.chunks.aggregate(chunksPerShardByNS_Aggregation);
{
"result" : [
{
"_id" : {
"shard" : "d42f619034d73616dabde1ed098739c2",
"ns" : "ChunkHunterTest.ChunkHunter"
},
"count" : 56
},
{
"_id" : {
"shard" : "d34ff18d819ea9dfeda0f638eae589f0",
"ns" : "ChunkHunterTest.ChunkHunter"
},
"count" : 57
},
{
"_id" : {
"shard" : "4fa0d97504185879b6e7524dda47d98b",
"ns" : "ChunkHunterTest.ChunkHunter"
},
"count" : 56
},
{
"_id" : {
"shard" : "0e5302a229a01e20cf4e29ae4f352c54",
"ns" : "chunktest.prefixsplit"
},
"count" : 3969
},
{
"_id" : {
"shard" : "af6e8730844faa627625a6c3fa98f0fc",
"ns" : "ChunkHunterTest.ChunkHunter"
},
"count" : 56
},
{
"_id" : {
"shard" : "0e5302a229a01e20cf4e29ae4f352c54",
"ns" : "ChunkHunterTest.ChunkHunter"
},
"count" : 57
}
],
"ok" : 1
}
mongos>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment