问题
Map Reduce is slow in Mongo. That is a given. So, I am wondering if it is possible to receive map reduce progress notifications.
Thanks.
回答1:
I don't know about any built-in features. You could, however, in a separate script run db.currentOp()
every once in a while, read map-reduce progress and notify concerned parties.
This is an example of what I can see:
> db.currentOp()
{
"inprog" : [
{
"opid" : 249198781,
"active" : true,
"lockType" : "read",
"waitingForLock" : false,
"secs_running" : 14,
"op" : "query",
"ns" : "mydb.mycoll",
"query" : {
"mapreduce" : "mycoll",
"map" : function cf__9__f_() {
emit(this.aid, 1);
},
"reduce" : function cf__10__f_(k, vals) {
var result = 0;
vals.forEach(function (v) {result += v;});
return result;
},
"out" : {
"inline" : 1
}
},
"client" : "127.0.0.1:44254",
"desc" : "conn",
"threadId" : "0x7e98f24e4700",
"connectionId" : 1958947,
"msg" : "m/r: (1/3) emit phase 644165/7670157 8%",
"progress" : {
"done" : 644165,
"total" : 7670157
},
"numYields" : 644
}
]
}
来源:https://stackoverflow.com/questions/11956942/is-it-possible-to-get-map-reduce-progress-notifications-in-mongo