Translate SQL to MongoDB MapReduce

本文比较了SQL与MapReduce的特点及适用场景。SQL以其简洁性和易用性受到欢迎,但MapReduce在处理大规模数据集时展现出更强的并行处理能力和硬件利用率。文章还提供了SQL到MongoDB MapReduce转换的实例。

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

I keep hearing people complaining that MapReduce is not as easy as SQL. But there are others saying SQL is not easy to grok. I’ll keep myself away from this possible flame war and just point you out to this ☞ SQL to MongoDB translation PDF put together by Rick Osborne and also his ☞ post providing some more details.

 

图片来源:http://huoding.com/wp-content/uploads/2011/03/SQL-to-MongoDB.png

 

As regards the SQL and MapReduce comparison, here’s what Rick has to say:

It seems kindof silly to go through all this, right? SQL does all of this, but with much less complexity. However, this approach has some huge advantages over SQL:

  1. Programmers who don’t know SQL or relational theory may find it easier to understand and get using quickly. (Newbies especially, such as my students.)
  2. The map and reduce functions can be heavily parallelized on commodity hardware.

It’s really that second one that is the key.

I’d also like to share something that I’ve learned lately: SQL parallel execution is supported in different forms by some RDBMS. So at the end of the day, it will probably become just a matter of what fits better the problem and your team.

 

文章来源:http://nosql.mypopescu.com/post/392418792/translate-sql-to-mongodb-mapreduce

推荐阅读:http://rickosborne.org/blog/2010/02/playing-around-with-mongodb-and-mapreduce-functions/

               http://blog.boxedice.com/2010/06/21/map-reduce-and-mongodb/  (通过MapReduce实现group操作)

               http://kylebanker.com/blog/2009/12/mongodb-map-reduce-basics/ (非常适合入门,介绍map/reduce方法)

               http://blog.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/ (sql到MapReduce)

               http://blog.evilmonkeylabs.com/2011/01/27/MongoDB-1_8-MapReduce/ (javascript 实现MapReduce)

               http://blog.evilmonkeylabs.com/2011/02/28/MongoDB-1_8-MR-Java/ (java实现MapReduce,其实map, reduce, finalize函数还是javascript实现的)