mongodb - How to reduce(improve) the execution of aggregate queries? -


i using mongodb 3.2 version. have 4 core, 15gb ram.

i have 80 millions records, when doing aggregate queries it's taking minimum 60 seconds 100 seconds each aggregate queries. how reduce time? have created index also.

please give idea/suggest me.

please refer sample document:

{ documentno: "001230001", collectedamount: 143.23, begindate: "2015-05-23" enddate: "2016-03-15", vendornumber: 123456, vendorname: "abc", . . . dept: 101, year: 2016, quarter: "q1" }

i have created indexes "documentno", "collectedamount", "vendornumber", "vendorname" "year"...etc

sample aggregate query:

db.collection.aggregate([ { '$match': { documentno: { '$regex': '123' } } }, { '$group': { _id: { documentno: '$documentno' }, amount: { '$sum': '$collectedamount' }, count: { '$sum': 1 } } } ])


Comments