# Kniffelig facet performance

**URL:** https://discuss.elastic.co/t/kniffelig-facet-performance/14037
**Category:** Elasticsearch
**Created:** [October 21, 2013, 12:44pm UTC](https://discuss.elastic.co/t/kniffelig-facet-performance/14037 "2013-10-21T12:44:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Min\_Cha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/min_cha/32/1131_2.png) [@Min\_Cha](https://discuss.elastic.co/u/Min_Cha)
#### Post date: [October 21, 2013, 12:44pm UTC](https://discuss.elastic.co/t/kniffelig-facet-performance/14037/1 "2013-10-21T12:44:58Z")

</div>

Hi folks.

I am very wondering about facet performance.  
I just added 10,000,000 docs and each doc has only two  
fields[userId,musicId].

When I queried as {"query":{"in":{"userId":["1000"]}}},  
this was very fast and matched only 17 docs;

{  
took: 3  
timed\_out: false  
\_shards: {  
total: 5  
successful: 5  
failed: 0  
}  
hits: {  
total: 17  
max\_score: 14.561651  
hits: [  
{  
\_index: music  
\_type: recomm  
\_id: FhFX708PTPK9bwmNsCWmXQ  
\_score: 14.561651  
\_source: {  
userId: 1000  
musicId: 16398  
}  
...  
}

However when I queried again along with facet, this was so slow.

{  
"size" : "0",  
"query":{"in":{"userId":["1000"]}},  
"facets":{"plays":{"terms":{"size":3,"field":"musicId"}}}  
}

took: 129

In my opinion if facet is computed only on searched 17 docs(userId=1000),  
this should be more fast than 129ms.

For more testing, I queried as "{  
"facets":{"plays":{"terms":{"size":3,"field":"musicId"}}}}". If I  
understand correctly, this query may access all docs. In practice, but,  
there is no big difference with above facet.

took: 279

I think that this is not memory issue and not cache issue because all of  
docs size is under 50mb.

What I am missing? Please give me some advice.  
Thanks for reading.

--  
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: ![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:11am UTC](https://discuss.elastic.co/t/kniffelig-facet-performance/14037/2 "2017-07-06T02:11:25Z")

</div>


