# How to tuning aggregation performance

**URL:** <https://discuss.elastic.co/t/how-to-tuning-aggregation-performance/44076>\
**Category:** Elasticsearch\
**Created:** [March 10, 2016, 8:00pm UTC](https://discuss.elastic.co/t/how-to-tuning-aggregation-performance/44076 "2016-03-10T20:00:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![QD\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/qd_wang/32/8409_2.png) [@QD\_Wang](https://discuss.elastic.co/u/QD_Wang)\
**Post date:** [March 10, 2016, 8:00pm UTC](https://discuss.elastic.co/t/how-to-tuning-aggregation-performance/44076/1 "2016-03-10T20:00:50Z")

</div>

Hi there

We have a problem with our ES aggregation query, it took 10-12s to execute.

so here is our cluster information

1. we have 1 client node, 3 master nodes and 6 data nodes
2. for data node, its 16 cores. and 64GB memory , we assigned 30gb to the heap
3. for each index, we have 6 shards and 1 replica.
4. Index size is around 15GB per day and 110 million records.
5. maximum of segment is 1.
6. ES version is 2.2, and doc\_value is enabled for all fields.
7. Query is across all indices , 114 shards, 2 Billion records and index size is 300GB.

here is my query

> ```
> {
> "size": 0,
> "query": {
> "filtered": {
> "filter": {
> "bool": {
> "must": [
> {
> "terms": {
> "_cache": true,
> "kName": {
> "index": "client_index",
> "type": "client",
> "id": "123",
> "path": "cId"
> }
> }
> }
> ]
> }
> }
> }
> },
> "aggs": {
> "dateTerms": {
> "terms": {
> "field": "date"
> },
> "aggs": {
> "searchD": {
> "terms": {
> "field": "prodLog",
> "size": 10
> }
> }
> }
> }
> }
> }
> 
> ```

partial response

> ```
> "took": 11570,
> "timed_out": false,
> "_shards": {
> "total": 114,
> "successful": 114,
> "failed": 0
> },
> "hits": {
> "total": 187772187,
> "max_score": 0,
> "hits": []
> 
> ```

so couple of questions.

1. since we enabled doc\_value, do we still need to assign 30gb to the heap?
2. when i fire the query , i do see cpu usage reached 90% -100% for couple of seconds. does that mean CPU is the bottleneck?
3. we have to do lots of terms agg against filed "prodLog" , should we disable doc\_value and enable field data cache?
4. is there any way to make it faster?

any comments are appreciated

Thanks  
Alps

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 12, 2016, 9:52am UTC](https://discuss.elastic.co/t/how-to-tuning-aggregation-performance/44076/2 "2016-03-12T09:52:04Z")

</div>

You may be oversharding, 6 shards for 15GB is excessive.

What sort of cardinality does that field have?

---

<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, 11:08pm UTC](https://discuss.elastic.co/t/how-to-tuning-aggregation-performance/44076/3 "2017-07-05T23:08:53Z")

</div>


