# Is it recommended to run es aggregations during api calls, how expensive can it be?

**URL:** <https://discuss.elastic.co/t/is-it-recommended-to-run-es-aggregations-during-api-calls-how-expensive-can-it-be/267084>\
**Category:** Elasticsearch\
**Created:** [March 12, 2021, 12:41pm UTC](https://discuss.elastic.co/t/is-it-recommended-to-run-es-aggregations-during-api-calls-how-expensive-can-it-be/267084 "2021-03-12T12:41:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish\_kakoti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manish_kakoti/32/53285_2.png) [@manish\_kakoti](https://discuss.elastic.co/u/manish_kakoti)\
**Post date:** [March 12, 2021, 12:41pm UTC](https://discuss.elastic.co/t/is-it-recommended-to-run-es-aggregations-during-api-calls-how-expensive-can-it-be/267084/1 "2021-03-12T12:41:24Z")

</div>

there are couple of scenarios that i wanted to discuss:

1. If we run aggregations (on large data sets) during REST API calls? How expensive it is experienced to be?

2. If we store pre-aggregated data(which runs during insertion of data in elastic search)? and we run queries to fetch them during API calls, can this be a great solution?

thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 12, 2021, 1:11pm UTC](https://discuss.elastic.co/t/is-it-recommended-to-run-es-aggregations-during-api-calls-how-expensive-can-it-be/267084/2 "2021-03-12T13:11:38Z")

</div>

Before doing option 2, I'd first check that there's actually a problem to solve.

1 is normally ok.

---

<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 9, 2021, 1:11pm UTC](https://discuss.elastic.co/t/is-it-recommended-to-run-es-aggregations-during-api-calls-how-expensive-can-it-be/267084/3 "2021-04-09T13:11:57Z")

</div>

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