# Elastic 2.0 slower query execution speed as 1.3

**URL:** https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973
**Category:** Elasticsearch
**Created:** [November 18, 2015, 4:58pm UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973 "2015-11-18T16:58:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Jayme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayme/32/6008_2.png) [@Jayme](https://discuss.elastic.co/u/Jayme)
#### Post date: [November 18, 2015, 4:58pm UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973/1 "2015-11-18T16:58:07Z")

</div>

Hi,  
I'm having an index of around 140M entries, still running elastic 1.3 in production and using filtered queries to do lookups, most of the queries execute in sub 100ms, between 40 and 100ms.

I now have a new server with almost the same hardware specs and upgraded to 2.0.  
I followed the guidelines that were posted here: [https://www.elastic.co/blog/better-query-execution-coming-elasticsearch-2-0](https://www.elastic.co/blog/better-query-execution-coming-elasticsearch-2-0)

The query I'm running is :

> <https://gist.github.com/jrots/83c5a6edd4ff0c340128>

  
And first hit is around 900ms all subsequent ones take around 230ms

I'm a bit dissapointed with this not so "fast" speed. .  
Are there any things I can optimize further to this query or things you see I'm doing wrong with it?  
I just want to make sure I'm making full use of the Roaring bitmaps and that is everything is wrapped in constantScore.

This is the explain of some of the results:

> <https://gist.github.com/jrots/27f60dfc736545700d24>

Thanks,  
Jayme

---

<div class="post-metadata">

### Author: ![vignesh\_c](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@vignesh\_c](https://discuss.elastic.co/u/vignesh_c)
#### Post date: [November 18, 2015, 11:02pm UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973/2 "2015-11-18T23:02:59Z")

</div>

Hi Jayme,

I was having a very similar problem. Though it was with queries and not filters.

You could have a look at "query\_cache" property in \_nodes/stats?pretty=true for both 2.0 as well as for 1.3, if you are seeing any differences there. ([https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-cache.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-cache.html))

You can try tweaking the cache size, to see if that solves/ reduces your problem.

In my case, the "query\_cache" was being used even though the queries were not being executed as a filter. And the miss count was quite high.  
More details : [Search is slower in ElasticSearch 2.0.0 than 1.7.3 when the document count is high ( \> 2.5 million)](https://discuss.elastic.co/t/search-is-slower-in-elasticsearch-2-0-0-than-1-7-3-when-the-document-count-is-high-2-5-million/34593)

Unfortunately, I do not have any more information on this. Hopefully an expert can throw more light on these issues.

Thanks,  
Vignesh

---

<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 19, 2015, 2:29pm UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973/3 "2015-11-19T14:29:36Z")

</div>

Hi Jayme,

Indeed, there is one optimization that was lost when moving to the `bool` query instead of `filtered`, we are going to add it back through [https://issues.apache.org/jira/browse/LUCENE-6889](https://issues.apache.org/jira/browse/LUCENE-6889).

In the mean time you should be able to get back similar speed as before by replacing queries that look like this:

```auto
{
  "bool": {
    "must": { "match_all": {} },
   "filter": { "some_filter...": {}}
  }
}

```

to

```auto
{
  "constant_score": {
   "filter": { "some_filter...": {}}
  }
}

```

Both queries will match the same documents and give the same scores. This is something that was performed automatically by the `filtered` query before but that `bool` does not do until LUCENE-6889 is in.

---

<div class="post-metadata">

### Author: ![Jayme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayme/32/6008_2.png) [@Jayme](https://discuss.elastic.co/u/Jayme)
#### Post date: [November 23, 2015, 2:53pm UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973/4 "2015-11-23T14:53:31Z")

</div>

Great, thanks for the help!  
That indeed looks already much better in terms of execution speed.

---

<div class="post-metadata">

### Author: ![xzer\_LR](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@xzer\_LR](https://discuss.elastic.co/u/xzer_LR)
#### Post date: [February 1, 2016, 8:20am UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973/5 "2016-02-01T08:20:55Z")

</div>

I got similar issue after I migrated to elasticsearch 2.0.2. I tried to change the bool query to constant\_score as suggested above, but I did not get any performance up.

I also tried to change the query cache to cache everthing with bigger cache size/count, which gave me a little bit of speep up but still slower than 1.7.3 vastly against the same queries.

Most of my queries are filter only, no scoring required, is there any suggestion to make the 2.0.2 works as the same speed as 1.7.3?

---

<div class="post-metadata">

### Author: ![Jayme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayme/32/6008_2.png) [@Jayme](https://discuss.elastic.co/u/Jayme)
#### Post date: [February 1, 2016, 3:32pm UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973/6 "2016-02-01T15:32:36Z")

</div>

try putting index.queries.cache.everything: true  
in your config, it made a big difference for me

---

<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 5, 2017, 11:19pm UTC](https://discuss.elastic.co/t/elastic-2-0-slower-query-execution-speed-as-1-3/34973/7 "2017-07-05T23:19:51Z")

</div>


