# Performance consider for parent child aggregration

**URL:** https://discuss.elastic.co/t/performance-consider-for-parent-child-aggregration/224434
**Category:** Elasticsearch
**Created:** [March 20, 2020, 2:39pm UTC](https://discuss.elastic.co/t/performance-consider-for-parent-child-aggregration/224434 "2020-03-20T14:39:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mitelastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mitelastic/32/72743_2.png) [@mitelastic](https://discuss.elastic.co/u/mitelastic)
#### Post date: [March 20, 2020, 2:39pm UTC](https://discuss.elastic.co/t/performance-consider-for-parent-child-aggregration/224434/1 "2020-03-20T14:39:42Z")

</div>

Hi, I am looking for some review on my below aggregate query, any feedback would be great as I am pretty new to Elastic Search.  
I have index like  
Email(parent) {senderIp:ipadd, RecieptCount:num, Join:{Campaign}}  
Campaign (child) { Name:string,parentkey}.  
Now the requirement is apply a filter on email, group by Email received Time, then group by campaign name and get the sum of receipt in each campaign.  
eg.  
ReceivedTime:{Bucket:[key: "10-1-2020", value:{  
Bucket:[{  
key:Camp1,  
receiptCount:100},  
{key:camp2,receiptCount:1}]}]

Now I am apply below aggregate and would like to understand the performance consideration and if there is any other way around.  
{  
"summarizeByDateAggregate": {  
"date\_histogram": {  
"field": "ReceivedTime",  
"interval": "1h"  
},  
"aggs": {  
"summarizeByCampaign": {  
"children": {  
"type": "campaigndata"  
},  
"aggs": {  
"summarizeByCampaignType": {  
"terms": {  
"field": "CampaignName",  
"size": 20,  
"shard\_size": 60  
},  
"aggs": {  
"parentAggregate": {  
"parent": {  
"type": "campaigndata"  
},  
"aggs": {  
"recipientCountAgg": {  
"sum": {  
"field": "RecipientsCount"  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
As once I apply children aggregate, I need to go for parent aggregate as I want to apply sum on parent. (otherwise its not recognizing Receipt Count which kind of make sense because than its only looking into current document)  
My understand it should not be big performance issue as Elastic will only be doing bucketing on documents and fetching is already done

---

<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: [April 17, 2020, 2:39pm UTC](https://discuss.elastic.co/t/performance-consider-for-parent-child-aggregration/224434/2 "2020-04-17T14:39:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
