# Nested Terms Aggregation performance issue?

**URL:** <https://discuss.elastic.co/t/nested-terms-aggregation-performance-issue/18469>\
**Category:** Elasticsearch\
**Created:** [July 3, 2014, 5:51pm UTC](https://discuss.elastic.co/t/nested-terms-aggregation-performance-issue/18469 "2014-07-03T17:51:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [July 3, 2014, 5:51pm UTC](https://discuss.elastic.co/t/nested-terms-aggregation-performance-issue/18469/1 "2014-07-03T17:51:40Z")

</div>

I ran into a performance issue today with nested Terms aggregations.  
Performance took a 1000x dive (aggregation time went from ~10ms to  
~10,000ms) when I added a terms aggregation as a sub-aggregation of an  
existing term aggregation.

The nature of the data is that the sub-aggregation will only yield 1 bucket

- so its not like there were a bazillion buckets - but we do kind of have a  
deep nesting of aggregations - and this particular aggregation lies at the  
leaf of all aggregations.

That said, would such a jump in performance be expected? Might it be a bug?  
Should I create a simple test case to reproduce it?

(If youre wondering why I would do a term aggregation where I only expect 1  
result - see  
[https://groups.google.com/forum/?fromgroups=#!topic/elasticsearch/y5WTIIAxEPo](https://groups.google.com/forum/?fromgroups=#!topic/elasticsearch/y5WTIIAxEPo))

Here is part of my request:  
{

```
      "aggregations" : {
        "operatorId" : {
          "terms" : {
            "field" : "operatorId",
            "size" : 100
          },
          "aggregations" : { <<------ adding this subaggregation has a 

```

massive impact on perf.  
"operatorFullName" : {  
"terms" : {  
"field" : "operatorFullName"  
}  
}  
}  
}  
}

Cheers,  
-M

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b506a4cf-d600-483c-8813-3f2f1e6eff4d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b506a4cf-d600-483c-8813-3f2f1e6eff4d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:18am UTC](https://discuss.elastic.co/t/nested-terms-aggregation-performance-issue/18469/2 "2017-07-06T01:18:04Z")

</div>


