Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:34:49+00:00 2026-06-11T02:34:49+00:00

I am somewhat confused about when to use group(), aggregate with $group or mapreduce.

  • 0

I am somewhat confused about when to use group(), aggregate with $group or mapreduce. I read the documentation at http://www.mongodb.org/display/DOCS/Aggregation for group(), http://docs.mongodb.org/manual/reference/aggregation/group/#_S_group for $group.. Is sharding the only situation where group() won’t work? Also, I get this feeling that $group is more powerful than group() because it can be used in conjunction with other pipeline operators from aggregation framework.. How does $group compare with mapreduce? I read somewhere that it doesn’t generate any temporary collection whereas mapreduce does. Is that so?
Can someone present an illustration or guide me to a link where these three concepts are explained together, taking the same sample data, so I can compare them easily?

EDIT:
Also, it would be great if you can point out anything new specifically in these commands since the new 2.2 release came out..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:34:50+00:00Added an answer on June 11, 2026 at 2:34 am

    It is somewhat confusing since the names are similar, but the group() command is a different feature and implementation from the $group pipeline operator in the Aggregation Framework.

    The group() command, Aggregation Framework, and MapReduce are collectively aggregation features of MongoDB. There is some overlap in features, but I’ll attempt to explain the differences and limitations of each as at MongoDB 2.2.0.

    Note: inline result sets mentioned below refer to queries that are processed in memory with results returned at the end of the function call. Alternative output options (currently only available with MapReduce) could include saving results to a new or existing collection.

    group() Command

    • Simple syntax and functionality for grouping .. analogous to GROUP BY in SQL.

    • Returns result set inline (as an array of grouped items).

    • Implemented using the JavaScript engine; custom reduce() functions can be written in JavaScript.

    • Current Limitations

      • Will not group into a result set with more than 20,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.

      • Does not work with sharded collections.

    • See also: group() command examples.

    MapReduce

    • Implements the MapReduce model for processing large data sets.

    • Can choose from one of several output options (inline, new collection, merge, replace, reduce)

    • MapReduce functions are written in JavaScript.

    • Supports non-sharded and sharded input collections.

    • Can be used for incremental aggregation over large collections.

    • MongoDB 2.2 implements much better support for sharded map reduce output.

    • Current Limitations

      • A single emit can only hold half of MongoDB’s maximum BSON document size (16MB).

      • There is a JavaScript lock so a mongod server can only execute one JavaScript function at a point in time .. however, most steps of the MapReduce are very short so locks can be yielded frequently.

      • MapReduce functions can be difficult to debug. You can use print() and printjson() to include diagnostic output in the mongod log.

      • MapReduce is generally not intuitive for programmers trying to translate relational query aggregation experience.

    • See also: Map/Reduce examples.

    Aggregation Framework

    • New feature in the MongoDB 2.2.0 production release (August, 2012).

    • Designed with specific goals of improving performance and usability.

    • Returns result set inline.

    • Supports non-sharded and sharded input collections.

    • Uses a “pipeline” approach where objects are transformed as they pass through a series of pipeline operators such as matching, projecting, sorting, and grouping.

    • Pipeline operators need not produce one output document for every input document: operators may also generate new documents or filter out documents.

    • Using projections you can add computed fields, create new virtual sub-objects, and extract sub-fields into the top-level of results.

    • Pipeline operators can be repeated as needed (for example, multiple $project or $group steps.

    • Current Limitations

      • Results are returned inline, so are limited to the maximum document size supported by the server (16MB)

      • Doesn’t support as many output options as MapReduce

      • Limited to operators and expressions supported by the Aggregation Framework (i.e. can’t write custom functions)

      • Newest server feature for aggregation, so has more room to mature in terms of documentation, feature set, and usage.

    • See also: Aggregation Framework examples.

    Can someone present an illustration or guide me to a link where these three concepts are explained together, taking the same sample data, so I can compare them easily?

    You generally won’t find examples where it would be useful to compare all three approaches, but here are previous StackOverflow questions which show variations:

    • group() versus Aggregation Framework
    • MapReduce versus Aggregation Framework
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am somewhat confused about how the group by command works in mysql. Suppose
I'm somewhat confused about the lifecycle of ManagedBeans of type request. In this example
I am somewhat confused about memory allocation of static variable in objective C. should
I somewhat confused because I've read that everything should be possible at IRQL_PASSIVE, but
I am somewhat confused about when things are allocated on the heap (and I
I am somewhat confused about presence of two seemingly identical VB.NET functions: CType(args) and
I'm somewhat confused about using Nginx and Thin for serving my Rails 3.2 app.
I am somewhat confused about a paragraph in the code complete book. In the
I am learning about SOAP implementation and have become somewhat confused regarding the appropriate
i am studying about views in sql and somewhat confused and having the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.