Mongodb 聚合框架是否比 map/reduce 更快? [英] Is Mongodb Aggregation framework faster than map/reduce?

查看:37
本文介绍了Mongodb 聚合框架是否比 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,058 毫秒
聚合框架: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,803 毫秒
聚合框架:1,535 毫秒

MapReduce: 18,803ms
Aggregation Framework: 1,535ms

这些与我之前的实验非常一致.

Those are very much in line with my previous experiments.

这篇关于Mongodb 聚合框架是否比 map/reduce 更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆