I have a process that I'm currently using Mongo's Map/Reduce framework for, but it's not performing very well. It's a pretty simple aggregation, where I bucketize over 3 fields, returning the sum of 4 different fields, and passing through the values for another 4 fields (which are constant within each bucket).
For reasons described in [ Map-Reduce performance in MongoDb 2.2, 2.4, and 2.6 ], I'd like to convert this to the aggregation framework for better performance, but there are 3 things standing in the way, I think:
- The total result can be large, exceeding Mongo's 16MB limit, even though any one document in the result is very small.
- I can map/reduce directly to another collection, but the aggregation framework can only return results inline (I think?)
- For incremental updates as more data arrives in the source collection, I can map/reduce with
MapReduceCommand.OutputType
(in Java) set toREDUCE
, exactly matching my use case, but I don't see a corresponding functionality in the aggregation framework.
Are there good ways to solve these in the aggregation framework? The server is version 2.4.3 right now - we can probably update as needed if there are new capabilities.