The bigger problem is that a lot of the JS stuff is actually pretty
slow to bootstrap on the server-side. This is one of the reasons why
we recommend M/R for offline aggregation/ETL and not for real-time
aggregation. We're going to be looking at other (faster) ways to
handle aggregation in 1.7.
> Stats:
>
>> db.stats()
> {
> "collections" : 6,
> "objects" : 13457696,
> "avgObjSize" : 200.57336560433524,
> "dataSize" : 2699255380,
> "storageSize" : 2919419648,
> "numExtents" : 37,
> "indexes" : 4,
> "indexSize" : 1117423488,
> "fileSize" : 8519680000,
> "ok" : true
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.
>
You may want to try emitting and returning single values rather than objects. Object creation can be expensive, plus you can now use Array.sum () in your reduce.
On Jul 13, 2010 9:56 AM, "Michael Dirolf" <mi...@10gen.com> wrote:
One thing to try is running the query portion of your M/R as a
separate query, with explain. Since your query is doing a scan that
could affect performance (but probably only slightly).
The bigger problem is that a lot of the JS stuff is actually pretty
slow to bootstrap on the server-side. This is one of the reasons why
we recommend M/R for offline aggregation/ETL and not for real-time
aggregation. We're going to be looking at other (faster) ways to
handle aggregation in 1.7.
On Tue, Jul 13, 2010 at 5:08 AM, Chancey <chan...@gmail.com> wrote:
> Why MapReduce is sooooooo s...
M/R Process:
> db.runCommand({
... mapreduce: "out",
... query: {
... date: 20100203,
... link: 'http://www.163.com/'
... },
... map: function() { emit(
... {hour: this.hour},
... {hit: this.hits}
... );},
... reduce: function(key, vals) {
... var ret = {hit: 0};
... for(var i=0;i < vals.length; i++) {
... ret.hit += Number(vals[i].hit);
... }
... return ret;
... },
... out: 'result',
... verbose: true
... });
{
"result" : "result",
"timeMillis" : 1278,
"timing" : {
"mapTime" : NumberLong( 44 ),
"emitLoop" : 1272,
"total" : 1278
},
"counts" : {
"input" : 787,
"emit" : 787,
"output" : 24
},
"ok" : true
}
M/R Log:
[conn2] Wed Jul 14 10:48:49 CMD: drop tjt.tmp.mr.mapreduce_1279075729_10
[conn2] Wed Jul 14 10:48:49 CMD: drop tjt.tmp.mr.mapreduce_1279075729_10_inc
[conn2] Wed Jul 14 10:48:49 query tjt.$cmd ntoreturn:1 command: { count:
"out", query: { date: 20100203.0, link: "http://www.163.com/" } }
reslen:57 658ms
[conn2] Wed Jul 14 10:48:50 building new index on { 0: 1 } for
tjt.tmp.mr.mapreduce_1279075729_10_inc
[conn2] Wed Jul 14 10:48:50 Buildindex
tjt.tmp.mr.mapreduce_1279075729_10_inc idxNo:0 { ns:
"tjt.tmp.mr.mapreduce_1279075729_10_inc", key: { 0: 1 }, name: "0_1" }
[conn2] Wed Jul 14 10:48:50 done for 24 records 0secs
[conn2] Wed Jul 14 10:48:50 building new index on { _id: 1 } for
tjt.tmp.mr.mapreduce_1279075729_10
[conn2] Wed Jul 14 10:48:50 Buildindex
tjt.tmp.mr.mapreduce_1279075729_10 idxNo:0 { name: "_id_", ns:
"tjt.tmp.mr.mapreduce_1279075729_10", key: { _id: 1 } }
[conn2] Wed Jul 14 10:48:50 done for 0 records 0secs
[conn2] Wed Jul 14 10:48:50 CMD: drop tjt.tmp.mr.mapreduce_1279075729_10_inc
[conn2] Wed Jul 14 10:48:50 CMD: drop tjt.result
[conn2] Wed Jul 14 10:48:50 query tjt.$cmd ntoreturn:1 command: {
mapreduce: "out", query: { date: 20100203.0, link: "http://www.163.com/"
}, map: function () {
emit({hour:this.hour}, {hit:this.hits});
}, reduce: function (key, vals) {
var ret = {hit:0};
for (var i = 0; i < ..., out: "result", verbose: true } reslen:182
1278ms
GROUP() Process:
db.out.group({
key: {hour:true},
cond: {date: 20100203,
link: "http://www.163.com/"},
reduce: function(obj,prev) {
prev.hit += Number(obj.hits);
},
initial: {hit: 0}
});
GROUP() Log:
[conn2] Wed Jul 14 11:00:08 query tjt.$cmd ntoreturn:1 command: { group:
{ key: { hour: true }, cond: { date: 20100203.0, link:
"http://www.163.com/" }, initial: { hit: 0.0 }, ns: "out", $reduce:
function (obj, prev) {
prev.hit += Number(obj.hits);
} } } reslen:938 650ms