when to use mongodb's aggregate framework?

Go To StackoverFlow.com

0

I have researched the aggregate framework of mongodb 2.1. And I have done a test.

var drugstore = {
    id: 860011001238937,
    name: "store1",    
    transaction_flow: [
        {
        pepdate: 20120327,
        create_date: "2012-3-27 16:36:33",
        trace: "000256",
        peopleid: "123456",        
        tranamt: 1000,
       },
        {
        pepdate: 20120405,
        create_date: "2012-3-27 16:36:33",
        trace: "000256",
        peopleid: "123456",        
        tranamt: 1000,
       }
                ]
};

after I inserted 40 thousand datas into transaction_flow, the mongodb is crashed. And I know the limit size of mongodb's document is 16Mb, now the drugstore collection is 22Mb. So the aggregate commands, ex. unwind, why design this command, and when to use?

2012-04-05 15:54
by avatas
Have you tried using is across documents? Right now you just have one massive document - Nik 2012-04-05 16:01
@Nik what is across document - avatas 2012-04-06 02:23
You only have a single document here - drugstore, and 40000 transactionflows within it. Instead what you probably want is to insert one document for drugstore, and 40000 distinct documents (not nested in drugstore) for transactionflow. Mongo works well with lots of small documents - Nik 2012-04-06 11:26


0

The maximum size to any result of MongoDB commands is limited to 64MB. There is an ongoing ticket that will add an out option similar to the map reduce command where you can potentially dump the result into a new collection.

2012-04-05 16:19
by Ren
Thanks for your answer,but my question is the sub array objects of a document is limited by 16MB, and it can't meet my requirements - avatas 2012-04-05 17:17
@avatas: The current document limit (as of MongoDB 2.2) is 16Mb, and this is also the limit of results that can be returned via the Aggregation Framework or Map/Reduce with inline output. If you are trying to return more than 16Mb of manipulated results, you would want to use Map/Reduce with output to a collection - Stennie 2012-09-19 01:23
Ads