# Large number of facets slow down the filter query

**URL:** https://discuss.elastic.co/t/large-number-of-facets-slow-down-the-filter-query/11665
**Category:** Elasticsearch
**Created:** [April 23, 2013, 10:19am UTC](https://discuss.elastic.co/t/large-number-of-facets-slow-down-the-filter-query/11665 "2013-04-23T10:19:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![deer](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@deer](https://discuss.elastic.co/u/deer)
#### Post date: [April 23, 2013, 10:19am UTC](https://discuss.elastic.co/t/large-number-of-facets-slow-down-the-filter-query/11665/1 "2013-04-23T10:19:06Z")

</div>

Hi All,

Here is my case,

1. Prepare the index :  
[https://gist.github.com/hui1103/5442389#file-prepare-the-index](https://gist.github.com/hui1103/5442389#file-prepare-the-index)

2. Normal query :  
[https://gist.github.com/hui1103/5442389#file-normal-query](https://gist.github.com/hui1103/5442389#file-normal-query)  
running such normal(just a few facets) requires less than 10ms.

3. Problem query :  
[https://gist.github.com/hui1103/5442389#file-problem-query](https://gist.github.com/hui1103/5442389#file-problem-query)  
when facet become more and more(\>999) and the query requires more than  
1000ms.

Can I ask is there any faster way for my filter query with large number of  
facets?

Many Thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![deer](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@deer](https://discuss.elastic.co/u/deer)
#### Post date: [April 23, 2013, 1:22pm UTC](https://discuss.elastic.co/t/large-number-of-facets-slow-down-the-filter-query/11665/2 "2013-04-23T13:22:31Z")

</div>

Hi,

I have found the following thread ,

​http://elasticsearch-users.115913.n3.nabble.com/Performance-killed-when-faceting-on-high-cardinality-fields-td4007161.html

I am not sure if I can use the mentioned solution in the above thread.

the facet in this post is used to avoid the OOM which happens when facet on the high cardinality field under machine with less memory.

only the necesary tags are selected for facet(not all tag of the field)...

---

<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, 2:39am UTC](https://discuss.elastic.co/t/large-number-of-facets-slow-down-the-filter-query/11665/3 "2017-07-06T02:39:57Z")

</div>


