# How is memory usage of aggregration

**URL:** <https://discuss.elastic.co/t/how-is-memory-usage-of-aggregration/63485>\
**Category:** Elasticsearch\
**Created:** [October 20, 2016, 9:08am UTC](https://discuss.elastic.co/t/how-is-memory-usage-of-aggregration/63485 "2016-10-20T09:08:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [October 20, 2016, 9:08am UTC](https://discuss.elastic.co/t/how-is-memory-usage-of-aggregration/63485/1 "2016-10-20T09:08:44Z")

</div>

when I query like this:  
{  
"size" : 0,  
"query" : {  
"match\_all" : { }  
},  
"aggregations" : {  
"filter" : {  
"filter" : {  
"match\_all" : { }  
},  
"aggregations" : {  
"createdAt\_1h" : {  
"date\_histogram" : {  
"field" : "createdAt",  
"interval" : "1h",  
"time\_zone" : "Asia/Shanghai"  
},  
"aggregations" : {  
"sum(num)" : {  
"sum" : {  
"field" : "num"  
}  
},  
"sum(price)" : {  
"sum" : {  
"field" : "price"  
}  
}  
}  
}  
}  
}  
}  
}

and if search tps is high, the node will show memory issue.  
so I'd like to ask:  
the coordinator of aggregration like this will only get mid-results like this:  
"buckets": [  
{  
"doc\_count": XXX,  
"sum(num)": {  
"value": XXX  
},  
"sum(price)": {  
"value": XXX  
},  
"key": 1476806400000  
},

and sum them up or the coordinator get raw doc and sum them up in its memory?

and if it is latter, should we open a issue to optimize it?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:10pm UTC](https://discuss.elastic.co/t/how-is-memory-usage-of-aggregration/63485/2 "2017-07-05T22:10:58Z")

</div>


