# Performance based on length of "terms"

**URL:** <https://discuss.elastic.co/t/performance-based-on-length-of-terms/7081>\
**Category:** Elasticsearch\
**Created:** [March 21, 2012, 9:46am UTC](https://discuss.elastic.co/t/performance-based-on-length-of-terms/7081 "2012-03-21T09:46:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pravinhmhatre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pravinhmhatre/32/2949_2.png) [@pravinhmhatre](https://discuss.elastic.co/u/pravinhmhatre)\
**Post date:** [March 21, 2012, 9:46am UTC](https://discuss.elastic.co/t/performance-based-on-length-of-terms/7081/1 "2012-03-21T09:46:22Z")

</div>

I have following criteria in the query. The terms list for seen by can grow significantly large. There are also a couple of similar kind of list in "must\_not" clause and those can be grow large too.

```
{
                "terms": {
                  "seen_by": [
                    "54",
                    "3",
                    "418",
                    "411",
                    "1",
                    "101"
                  ]
                }
              }
```

What will be the performance difference if the list of terms in conditions grows or shrinks?

Thanks,  
Pravin

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 25, 2012, 11:26am UTC](https://discuss.elastic.co/t/performance-based-on-length-of-terms/7081/2 "2012-03-25T11:26:14Z")

</div>

Hard to answer with exact numbers, the performance will be slower,  
obviously, as the list grows. Though, what I suggest is to use terms filter  
in this case with execution mode set to bool (new in 0.19:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html)).  
This means that the cached filter will be per term, and you will get a  
considerably better filter cache hit ration in this case, meaning that for  
common terms, it will be a complete in memory bitwise operations.

On Wed, Mar 21, 2012 at 11:46 AM, pravinhmhatre [pravinhmhatre@gmail.com](mailto:pravinhmhatre@gmail.com)wrote:

> I have following criteria in the query. The terms list for seen by can  
> grow significantly large. There are also a couple of similar kind of list  
> in "must\_not" clause and those can be grow large too.
> 
> ```
> {
> "terms": {
> "seen_by": [
> "54",
> "3",
> "418",
> "411",
> "1",
> "101"
> ]
> }
> }
> 
> ```
> 
> ## What will be the performance difference if the list of terms in conditions grows or shrinks? Thanks, Pravin
> 
> View this message in context: Performance based on length of "terms"[http://elasticsearch-users.115913.n3.nabble.com/Performance-based-on-length-of-terms-tp3845134p3845134.html](http://elasticsearch-users.115913.n3.nabble.com/Performance-based-on-length-of-terms-tp3845134p3845134.html)  
> Sent from the Elasticsearch Users mailing list archive[http://elasticsearch-users.115913.n3.nabble.com/](http://elasticsearch-users.115913.n3.nabble.com/)at [Nabble.com](http://Nabble.com).

---

<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:34am UTC](https://discuss.elastic.co/t/performance-based-on-length-of-terms/7081/3 "2017-07-06T03:34:55Z")

</div>


