Database Manual / Aggregation Operations / Map-Reduce

Map-Reduce Concurrency

Note

Aggregation Pipeline as an Alternative to Map-Reduce

Starting in MongoDB 5.0, map-reduce is deprecated:

  • Instead of map-reduce, you should use an aggregation pipeline. Aggregation pipelines provide better performance and usability than map-reduce.

  • You can rewrite map-reduce operations using aggregation pipeline stages, such as $group, $merge, and others.

  • For map-reduce operations that require custom functionality, you can use the $accumulator and $function aggregation operators. You can use those operators to define custom aggregation expressions in JavaScript.

For examples of aggregation pipeline alternatives to map-reduce, see:

The map-reduce operation is composed of many tasks, including reads from the input collection, executions of the map function, executions of the reduce function, writes to a temporary collection during processing, and writes to the output collection.

During the operation, map-reduce takes the following locks: