group() vs aggregation framework vs MapReduce in mongodb

  • Will not group into a result set with more than 20,000 keys.(from mongo 2.2 version, in before versions limit is up to 10,000 keys)
  • Results must fit within the limitations of a BSON document (currently 16MB).
  • Takes a read lock and does not allow any other threads to execute JavaScript while it is running.
  • Can be used for incremental aggregation over large collections.
  • There have been significant improvements in Map/Reduce in MongoDB version 2.4. The SpiderMonkey JavaScript engine has been replaced by the V8 JavaScript engine, and there is no longer a global JavaScript lock, which means that multiple Map/Reduce threads can run concurrently.
  • In MapReduce inline output collection we can’t perform find(), sort(), limit() operations.
  • A single emit can only hold half of MongoDB’s maximum BSON document size (16MB).
  • The Map/Reduce engine is still considerably slower than the aggregation framework, for two main reasons: (1)The JavaScript engine is interpreted, while the Aggregation Framework runs compiled C++ code.(2)The JavaScript engine still requires that every document being examined get converted from BSON to JSON; if you’re saving the output in a collection, the result set must then be converted from JSON back to BSON.
  • New feature in the MongoDB 2.2.0 production release
  • Uses a “pipeline” approach where objects are transformed as they pass through a series of pipeline operators such as match, project, sort, group, limit, skip, unwind and geonear.
  • Designed with specific goals of improving performance and usability.
  • Pipeline operators can be repeated as needed.
  • Aggregation frame work is 10 times faster than MapReduce.
  • If any single aggregation operation consumes more than 10 percent of system RAM
  • Output from the pipeline cannot exceed the BSON document size limit.
  • The aggregation pipeline cannot operate on values of the following types: symbol, Minkey, Maxkey, DBRef, Code, CodeWScope

The article was originally published at MicroPyramid blog.

--

--

--

Python, Django, Android and IOS, reactjs, react-native, AWS, Salesforce consulting & development company

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Hitting The Edge

Is Powershell Considered a Programming Language?

PyEBPF — eBPF proxy routines generation and Python callbacks (iovisor/bcc wrapper)

A New Pattern that Simplifies Operator Building

Largest Rectangle in Histogram

Why our ETL tool doesn’t do transformations

Container With Most Water — Python(Day 40)

Web Crawling [Java][Selenium]

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
MicroPyramid

MicroPyramid

Python, Django, Android and IOS, reactjs, react-native, AWS, Salesforce consulting & development company

More from Medium

A step by step how to start docker-compose container at boot

DATABASE IN PYTHON

Let’s have a look at the PostgreSQL CRUD operation

PostgreSQL

Demystifying Docker