if the all the docs were stored in memory I'd expect the sum to be a magnitude faster. Could someone explain why I'm in the seconds and not the msecs? Is there a parameter of some sort I can toggle to get mongo to store the docs in memory?
Hi Shiv,
There isn't any specific parameter to toggle; MongoDB uses memory-mapped files and will keep indexes and documents in memory based on your working set (ie. what you actively query). Over time this should grow to fit available memory:
http://www.mongodb.org/display/DOCS/Caching.
- compare the performance for the initial run versus successive runs; perhaps the data has not been loaded into memory yet
- on a cold server start you could use the new touch() command in MongoDB 2.2 to forcibly load indexes/data into memory
Can you also share the aggregation query you are using?
Cheers,
Stephen