Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Comparison of MongoDB aggregation commands

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Comparison of MongoDB aggregation commands

The following table provides a brief overview of the properties of the MongoDB aggregation command.

Aggregate

MapReduce

Group

Description

New additions in version 2.2.

Designed to provide the performance and availability of aggregation tasks.

Use the pipeline approach to transform objects and pass a sequence of pipe operators, such as $group, $match, and $sort.

For more information about pipe operators, see aggregate Pipe operators.

Implement Map-Reduce aggregation to handle big data collections.

Provide grouping function.

Slower than the aggregate command, less functional than the mapReduce command.

Key attribute

Pipe operators can be repeated as needed.

The pipe operator does not have to produce an output document for each input document.

You can also generate new documents or filter documents.

In addition to grouping operations, complex aggregation tasks and incremental aggregation of growing data sets can be implemented.

Check out the Map-Reduce sample and implement incremental Map-Reduce.

You can group either by existing fields or by calculating columns through the client-side keyf JavaScript function.

See "group" for more information and examples of using the keyf function.

Flexibility

Restricts the operators and expressions that support aggregation pipes.

However, you can add computed columns, create new virtual self-objects, and extract subcolumns to the top level of the result by using the $project pipe operator.

Check out "$project" for more information, and "aggregate pipe operator" for more information about all available pipe operators.

Client-side map, reduce, and finalize JavaScript functions provide scalability to aggregation logic.

Check out "mapReduce" for specific information and restrictions on functions.

The client-side reduce and finalize JavaScript functions provide scalability to grouping logic.

Check out "group" for specific information and restrictions on functions.

Output result

Return the results with various options (inline as a document containing a result set, a cursor for a result set) or store the results in a collection.

If you return an inline document that contains a result set, the result set is limited by the size of the BSON document.

Modifications in version 2.6:

You can return the result set as a cursor or store the result to a collection.

Returns the results with various options (inline, new collection, merge,replace,reduce). View mapReduce's details about the output options.

Modifications in version 2.2:

It provides better support for sharding map-reduce output than in previous versions.

Returns an array of inline results as a grouped entry.

The result set must meet the maximum BSON document size limit.

Modifications in version 2.2:

The returned array can contain up to 20000 elements; that is, a maximum of 20000 unique groups. Previous versions had a limit of 10000 elements.

Slice

Non-sharding and sharding input sets are supported.

Non-sharding and sharding input sets are supported.

Fragment collection is not supported.

Be careful

Prior to version 2.4, Javascript code was executed in a single thread.

Prior to version 2.4, Javascript code was executed in a single thread.

More information

View the aggregation pipeline and aggregate.

View Map-Reduce and mapReduce.

View the group.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report