# Performance of aggregations as opposed to facets

**URL:** <https://discuss.elastic.co/t/performance-of-aggregations-as-opposed-to-facets/20562>\
**Category:** Elasticsearch\
**Created:** [November 4, 2014, 4:43pm UTC](https://discuss.elastic.co/t/performance-of-aggregations-as-opposed-to-facets/20562 "2014-11-04T16:43:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron\_Sher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ron_sher/32/4472_2.png) [@Ron\_Sher](https://discuss.elastic.co/u/Ron_Sher)\
**Post date:** [November 4, 2014, 4:43pm UTC](https://discuss.elastic.co/t/performance-of-aggregations-as-opposed-to-facets/20562/1 "2014-11-04T16:43:44Z")

</div>

Hi,

I know that facets are deprecated and going to be removed eventually.

But, we currently use facets and we're fine with its current behavior.

My question is do aggregations offer any improvement in performance? Or  
maybe a degradation due to added functionality?

Any experience?

We're starting to run queries in a loop that may suggest that facets are  
actually (a bit) faster.

Thanks for your feedback,

Ron

--  
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/3d272687-cd03-45d4-972c-96570396b3e1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3d272687-cd03-45d4-972c-96570396b3e1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [November 5, 2014, 2:40pm UTC](https://discuss.elastic.co/t/performance-of-aggregations-as-opposed-to-facets/20562/2 "2014-11-05T14:40:08Z")

</div>

Aggregations are inherently slower than facets due to the increased  
flexibility. Aggregations are composable and the fact that you can feed any  
sub-aggregation with the documents that match a particular bucket makes the  
life of the JVM a bit harder. Facets can actually almost be considered as  
specialized aggregations (think of term\_stats as an inlined stats  
aggregation under terms).

That said, the lack of flexibility was also an issue with facets, and for  
instance the term\_stats facet did not have the same optimization as the  
terms facet did. This is something that is much better with aggregations  
since running terms or terms/stats actually use the same logic to build  
buckets per term.

Another thing to consider is that you can do MANY more things with  
aggregations: think of the top\_hits, cardinality, percentiles, children,  
... aggregations that did not have any equivalent with facets.

On Tue, Nov 4, 2014 at 5:43 PM, Ron Sher [ron.sher@gmail.com](mailto:ron.sher@gmail.com) wrote:

> Hi,
> 
> I know that facets are deprecated and going to be removed eventually.
> 
> But, we currently use facets and we're fine with its current behavior.
> 
> My question is do aggregations offer any improvement in performance? Or  
> maybe a degradation due to added functionality?
> 
> Any experience?
> 
> We're starting to run queries in a loop that may suggest that facets are  
> actually (a bit) faster.
> 
> Thanks for your feedback,
> 
> Ron
> 
> --  
> 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/3d272687-cd03-45d4-972c-96570396b3e1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3d272687-cd03-45d4-972c-96570396b3e1%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/3d272687-cd03-45d4-972c-96570396b3e1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/3d272687-cd03-45d4-972c-96570396b3e1%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j4HUyO96k2PLGhaVi6mEbq9xhsedr4fNnzx2F%2BRbL3NDQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4HUyO96k2PLGhaVi6mEbq9xhsedr4fNnzx2F%2BRbL3NDQ%40mail.gmail.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, 12:52am UTC](https://discuss.elastic.co/t/performance-of-aggregations-as-opposed-to-facets/20562/3 "2017-07-06T00:52:02Z")

</div>


