# Facets performance issue

**URL:** https://discuss.elastic.co/t/facets-performance-issue/9009
**Category:** Elasticsearch
**Created:** [September 13, 2012, 9:16am UTC](https://discuss.elastic.co/t/facets-performance-issue/9009 "2012-09-13T09:16:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Hua](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hua](https://discuss.elastic.co/u/Hua)
#### Post date: [September 13, 2012, 9:16am UTC](https://discuss.elastic.co/t/facets-performance-issue/9009/1 "2012-09-13T09:16:01Z")

</div>

Hi

Here is my facets:  
{"facets":{"DF":{"facet\_filter":{"and":[{"query":{"text":{"@type":"analytics\_stg"}}},{"range":{"timestamp":{"to":"1347495877557","include\_lower":true,"include\_upper":true,"from":"1347452677556"}}},{"not":{"query":{"term":{"status":"200"}}}},{"not":{"query":{"term":{"status":"304"}}}}]},"date\_histogram":{"field":"timestamp","interval":"hour"}}}}

I tried it with my ES cluster(2 machines) having 60 to 80 gb data and it  
costs 5+ mins for the first time. Then the search is quite quick, I guess  
there is cache on ES server side. But when I re-try the facet an hour  
later, it still costs many minutes to produce the result.

How can I speed up facets?

--

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [September 13, 2012, 9:21am UTC](https://discuss.elastic.co/t/facets-performance-issue/9009/2 "2012-09-13T09:21:11Z")

</div>

On Thu, 2012-09-13 at 02:16 -0700, Hua wrote:

> Hi
> 
> Here is my facets:  
> {"facets":{"DF":{"facet\_filter":{"and":[{"query":{"text":{"@type":"analytics\_stg"}}},{"range":{"timestamp":{"to":"1347495877557","include\_lower":true,"include\_upper":true,"from":"1347452677556"}}},{"not":{"query":{"term":{"status":"200"}}}},{"not":{"query":{"term":{"status":"304"}}}}]},"date\_histogram":{"field":"timestamp","interval":"hour"}}}}
> 
> I tried it with my ES cluster(2 machines) having 60 to 80 gb data and  
> it costs 5+ mins for the first time. Then the search is quite quick, I  
> guess there is cache on ES server side. But when I re-try the facet an  
> hour later, it still costs many minutes to produce the result.

You are correct: the data has to be loaded and cached by ES. Presumably  
you continue indexing new data, which is why the facet after an hour is  
slow again (there is new data to load).

In v 0.20 (not yet released) there is a warmup API which will warm up  
each new segment before it becomes visible to search.

In the meantime, you can just run a typical query in the background to  
force the loading and caching of the new data.

clint

> How can I speed up facets?
> 
> --

--

---

<div class="post-metadata">

### Author: ![Hua](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hua](https://discuss.elastic.co/u/Hua)
#### Post date: [September 13, 2012, 9:26am UTC](https://discuss.elastic.co/t/facets-performance-issue/9009/3 "2012-09-13T09:26:53Z")

</div>

Thanks for your help.

Is there a way to turn off the cache used for facets? I'm doing a tunning  
on facets filter to see whether it helps to speed up query, but the cache  
makes it hard to meature query time.

I'm using elasticsearch 0.19.9

--

---

<div class="post-metadata">

### Author: ![Hua](https://avatars.discourse-cdn.com/v4/letter/h/cdc98d/32.png) [@Hua](https://discuss.elastic.co/u/Hua)
#### Post date: [September 13, 2012, 9:30am UTC](https://discuss.elastic.co/t/facets-performance-issue/9009/4 "2012-09-13T09:30:56Z")

</div>

Forget to mention, if I add more machines to the cluster, will it improve  
the performance?

--

---

<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, 3:12am UTC](https://discuss.elastic.co/t/facets-performance-issue/9009/5 "2017-07-06T03:12:57Z")

</div>


