Skip to content

Instantly share code, notes, and snippets.

@rhyskeepence
Created September 6, 2012 08:59
Show Gist options
  • Save rhyskeepence/3653338 to your computer and use it in GitHub Desktop.
Save rhyskeepence/3653338 to your computer and use it in GitHub Desktop.
profile output
> db.runCommand({aggregate:"prod", pipeline:pipeline, explain:true});
{
"serverPipeline" : [
{
"query" : {
"_id" : {
"$gte" : 1346281200000
}
},
"projection" : {
"_id" : 1,
"jvmThreadCount" : 1
},
"cursor" : {
"cursor" : "BtreeCursor _id_",
"isMultiKey" : false,
"n" : 5491,
"nscannedObjects" : 5491,
"nscanned" : 5491,
"nscannedObjectsAllPlans" : 5491,
"nscannedAllPlans" : 5491,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 9,
"indexBounds" : {
"_id" : [
[
1346281200000,
1.7976931348623157e+308
]
]
},
"allPlans" : [
{
"cursor" : "BtreeCursor _id_",
"n" : 5491,
"nscannedObjects" : 5491,
"nscanned" : 5491,
"indexBounds" : {
"_id" : [
[
1346281200000,
1.7976931348623157e+308
]
]
}
}
],
"oldPlan" : {
"cursor" : "BtreeCursor _id_",
"indexBounds" : {
"_id" : [
[
1346281200000,
1.7976931348623157e+308
]
]
}
},
"server" : "horse:27017"
}
},
{
"$group" : {
"_id" : {
"$subtract" : [
"$_id",
{
"$mod" : [
"$_id",
86400000
]
}
]
},
"averagePerDay" : {
"$avg" : "$jvmThreadCount"
}
}
}
],
"ok" : 1
}
profile output:
{ "ts" : ISODate("2012-09-06T09:45:11.505Z"), "op" : "query", "ns" : "snoggin.system.profile", "query" : { }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 2, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(91), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(7), "w" : NumberLong(3) } }, "nreturned" : 2, "responseLength" : 1181, "millis" : 0, "client" : "10.240.225.83", "user" : "" }
{ "ts" : ISODate("2012-09-06T09:45:27.726Z"), "op" : "query", "ns" : "snoggin.system.indexes", "query" : { "expireAfterSeconds" : { "$exists" : true } }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 48, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(92), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(3), "w" : NumberLong(3) } }, "nreturned" : 0, "responseLength" : 20, "millis" : 0, "client" : "0.0.0.0", "user" : "" }
{ "ts" : ISODate("2012-09-06T09:45:42.397Z"), "op" : "command", "ns" : "snoggin.$cmd", "command" : { "aggregate" : "prod", "pipeline" : [ { "$match" : { "_id" : { "$gte" : 1346281200000 } } }, { "$group" : { "_id" : { "$subtract" : [ "$_id", { "$mod" : [ "$_id", 86400000 ] } ] }, "averagePerDay" : { "$avg" : "$jvmThreadCount" } } } ] }, "ntoreturn" : 1, "keyUpdates" : 0, "numYield" : 1, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(1963680), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(592495), "w" : NumberLong(4) } }, "responseLength" : 138, "millis" : 1371, "client" : "10.240.225.83", "user" : "" }
> db.runCommand({mapReduce:"prod", map:m, reduce:r, finalize:f, query: { "_id": { $gte: 1346281200000 }}, out: { inline : 1 }, explain:true, verbose:true});
{
"results" : [
{
"_id" : 1346198400000,
"value" : {
"aggregate" : 81.88888888888889,
"count" : 360,
"sum" : 29480
}
},
{
"_id" : 1346284800000,
"value" : {
"aggregate" : 90.47534593646462,
"count" : 5131,
"sum" : 464229
}
}
],
"timeMillis" : 399,
"timing" : {
"mapTime" : 326,
"emitLoop" : 398,
"reduceTime" : 37,
"mode" : "mixed",
"total" : 399
},
"counts" : {
"input" : 5491,
"emit" : 5491,
"reduce" : 56,
"output" : 2
},
"ok" : 1
}
profile output:
{ "ts" : ISODate("2012-09-06T09:44:51.384Z"), "op" : "query", "ns" : "snoggin.system.profile", "query" : { }, "ntoreturn" : 0, "ntoskip" : 0, "nscanned" : 0, "keyUpdates" : 0, "numYield" : 0, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(68), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(6), "w" : NumberLong(3) } }, "nreturned" : 0, "responseLength" : 20, "millis" : 0, "client" : "10.240.225.83", "user" : "" }
{ "ts" : ISODate("2012-09-06T09:45:09.225Z"), "op" : "command", "ns" : "snoggin.$cmd", "command" : { "mapReduce" : "prod", "map" : function __cf__5__f__anonymous_function() {
emit(this._id - this._id % 86400000, {aggregate:0, count:1, sum:this.jvmThreadCount});
}, "reduce" : function __cf__6__f__anonymous_function(name, values) {
var result = {aggregate:0, count:0, sum:0};
values.forEach(function (f) {result.sum += f.sum;result.count += f.count;});
return result;
}, "finalize" : function __cf__7__f__anonymous_function(who, res) {
if (res.count > 0) {
res.aggregate = res.sum / res.count;
}
return res;
}, "query" : { "_id" : { "$gte" : 1346281200000 } }, "out" : { "inline" : 1 } }, "ntoreturn" : 1, "keyUpdates" : 0, "numYield" : 54, "lockStats" : { "timeLockedMicros" : { "r" : NumberLong(549618), "w" : NumberLong(0) }, "timeAcquiringMicros" : { "r" : NumberLong(369940), "w" : NumberLong(3) } }, "responseLength" : 285, "millis" : 383, "client" : "10.240.225.83", "user" : "" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment