GROUP
Short Description
Grouping documents
Detailed Description​
In MongoDB explain plans, GROUP is an execution stage that appears when you use the $group stage in your aggregation pipeline.
What does it do?
- The GROUP stage collects documents together based on a specified key (or keys) and performs operations (like sum, average, count, etc.) on those groups.
- This is useful for creating summaries, totals, or statistics from your collection.
Example: If you want to count the number of movies released per year, you might use:
db.movies.aggregate([ { $group: { _id: "$year", count: { $sum: 1 } } }])
- Here,Â
$group organizes your documents by theÂyear field and counts how many movies are in each year.
Summary:
GROUP in an explain plan means MongoDB is combining documents into groups (based on your query) and doing any group-level calculations you asked for.
Additional Links​
Search online​
If this article doesn't have the information you need you can try searching online. Remember, you can contribute suggestions to this page.