MongoDB MapReduce实现的group问题

本文讨论了MongoDB中MapReduce的速度问题及其在不同场景下的表现,特别是在与传统数据库如Oracle进行对比时的性能差距。文章还探讨了MapReduce在分布式环境下以及在分片数据库上的使用情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用MapReduce写的group速度不行啊!!

 

1)来源MongoDB权威指南

The price of using MapReduce is speed: group is not particularly speedy, but
MapReduce is slower and is not supposed to be used in “real time.” You run
MapReduce as a background job, it creates a collection of results, and then
you can query that collection in real time.

2)http://stackoverflow.com/questions/2599943/mongodbs-performance-on-aggregation-queries

The idea is that you improve the performance of aggregation queries by using MapReduce on a sharded database that is distributed over multiple machines.

I did some comparisons of the performance of Mongo's Mapreduce with a group-by-select statement in Oracle on the same machine. I did find that Mongo was approximately 25 times slower. This means that I have to shard the data over at least 25 machines to get the same performance with Mongo as Oracle delivers on a single machine. I used a collection/table with approximately 14 million documents/rows.

Exporting the data from mongo via mongoexport.exe and using the exported data as an external table in Oracle and doing a group-by in Oracle was much faster than using Mongo's own MapReduce.

3)http://blog.evilmonkeylabs.com/2011/01/27/MongoDB-1_8-MapReduce/ (下面的comments)

No clever tricks, unfortunately. As long as MapReduce is single threaded, we're not able to use it. We need to be able to run a few dozen or a few hundred at once but since you only get one MapReduce running per shard, we had to go in another direction. It would be nice to take advantage of new changes, but until it moves beyond being one giant blocking operation...

Any ideas as to when it'll be multithreaded?

----------------

I don't believe anything is scheduled currently to increase concurrency within MapReduce; much of the limitation exists in the JavaScript engine itself.

There are plans for the next major release series of MongoDB to include new aggregation features which will cover many of the common tasks people currently use MapReduce for in a much simpler interface.

-----------------
Unfortunately, MR in 1.8 will still only be single-threaded, meaning you can essentially only run one job per shard. These new features will be really useful once you can run MRs in parallel and distributed.

4)indexes for map/reduce (http://groups.google.com/group/mongodb-user/browse_thread/thread/3327e58e92140407/a16a9a2fa4b143cf?show_docid=a16a9a2fa4b143cf)

测试显示建索引对Map/Reduce是没有帮助的!

5)一个mongodb issue ticket

http://jira.mongodb.org/browse/SERVER-1197


6)为什么不直接用group命令呢?

 

直接访问shard server端口:

-------------------------

Thu Mar 17 17:14:07 uncaught exception: group command failed: {
        "errmsg" : "exception: group() can't handle more than 10000 unique keys",
        "code" : 10043,
        "ok" : 0
}


-------------------
直接访问route server端口:
Thu Mar 17 17:05:59 uncaught exception: group command failed: { "ok" : 0, "errmsg" : "can't do command: group on sharded collection"

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值