Mongodb Aggregation Framework是否比map/reduce更快? [英] Is Mongodb Aggregation framework faster than map/reduce?
问题描述
mongodb 2.2中引入的聚合框架是否比map/reduce有任何特殊的性能改进?
Is the aggregation framework introduced in mongodb 2.2, has any special performance improvements over map/reduce?
如果是,为什么以及如何以及多少?
If yes, why and how and how much?
(我已经为自己做了一个测试,并且性能几乎相同)
(Already I have done a test for myself, and the performance was nearly same)
推荐答案
我亲自进行的每项测试(包括使用您自己的数据)都表明聚合框架比map reduce快很多,并且通常快一个数量级.
Every test I have personally run (including using your own data) shows aggregation framework being a multiple faster than map reduce, and usually being an order of magnitude faster.
仅获取您发布的数据的1/10(而不是清除操作系统缓存,而是先预热缓存-因为我想衡量聚合的性能,而不是分页数据需要多长时间)这个:
Just taking 1/10th of the data you posted (but rather than clearing OS cache, warming the cache first - because I want to measure performance of the aggregation, and not how long it takes to page in the data) I got this:
MapReduce:1,058ms
聚合框架:133ms
MapReduce: 1,058ms
Aggregation Framework: 133ms
从聚合框架中删除$ match和从mapReduce中删除{query:}(因为这两个都将只使用索引,而这不是我们想要测量的),然后按key2将整个数据集分组:
Removing the $match from aggregation framework and {query:} from mapReduce (because both would just use an index and that's not what we want to measure) and grouping the entire dataset by key2 I got:
MapReduce:18,803ms
聚合框架:1,535ms
MapReduce: 18,803ms
Aggregation Framework: 1,535ms
这些非常符合我以前的实验.
Those are very much in line with my previous experiments.
这篇关于Mongodb Aggregation Framework是否比map/reduce更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!