The $group operation is much slower for MongoDB 3.2/3.3 comparing to MongoDB 3.0 on Windows. I don't see the issue on OSX or Linux.
- MongoDB 3.0 on Windows:
Run the following commands to create the collection, index and then run the aggregation.
The aggregation is fast on 3.0:
- MongoDB 3.2 on Windows:
Run the same commands on a MongoDB 3.2 instance on Windows and it is much slower:
From the diagnostic data, there is "cursor open pinned" while the aggregation command is run, but I don't see the same on OSX. Is this the cause of the slowness on Windows? Diagnostic data is attached.
We've also tested the same aggregation on MongoDB 3.2 with MMAP storage engine, it is also slow. So this issue doesn't seem to relate to the storage engine.
Also, if I change the data set from:
The aggregation is faster on the second data set (both on MongoDB 3.2 on Windows):
- First data set
- Second data set:
It seems the $group operations would be slow if the result set is large, and this is more obvious on MongoDB 3.2 on Windows.