# ES 5.2 query performance much worse than ES 2.4?

**URL:** https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990
**Category:** Elasticsearch
**Created:** [February 14, 2017, 8:53am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990 "2017-02-14T08:53:08Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [February 14, 2017, 8:53am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/1 "2017-02-14T08:53:08Z")

</div>

I just upgraded our existing ES 2.4 cluster to ES 5.2 with following steps:

1. Take snapshot of all indices on ES 2.4 cluster
2. Remove the ES 2.4 cluster
3. Create new ES 5.2 cluster with same hardware configurations
4. Restore the last taken snapshot to new created cluster
5. Run load test

I found that the query performance on ES 5.2 is much worse then on old ES 2.4 cluster.

On old ES 2.4, the average response time is around 50 ms, now it is 240 ms.

Is this a known perf issue?

---

<div class="post-metadata">

### Author: ![Attila\_Nagy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/attila_nagy/32/46906_2.png) [@Attila\_Nagy](https://discuss.elastic.co/u/Attila_Nagy)
#### Post date: [February 14, 2017, 8:57am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/2 "2017-02-14T08:57:03Z")

</div>

We've seen similar degradation. Here the major slowdown was caused by parent-child relationships (defined in the mapping, but not used). Once we rebuilt the indexes without PC, average response times returned to the same interval like in 2.4, but still there are high peaks, which weren't in 2.4.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 14, 2017, 9:02am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/3 "2017-02-14T09:02:48Z")

</div>

What queries?  
What is your mapping?

---

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [February 14, 2017, 9:17am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/4 "2017-02-14T09:17:18Z")

</div>

Our index mapping is around 2000 lines, so not possible post here. Can I send the mapping and query DSL to your email?

And is it possible that the worse perf is due to migrating old 2.4 indices to 5.2? Can re-build the indices from scratch help resolve the issue?

Also, is there any ES 5.2 specific perf tuning strategy?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 14, 2017, 9:31am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/5 "2017-02-14T09:31:48Z")

</div>

Use gist/pastebin/etc 🙂

---

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [February 14, 2017, 10:31am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/6 "2017-02-14T10:31:26Z")

</div>

Here you go:  
[https://gist.github.com/youxu71/f8abceb3587be04474ca0d0921195564](https://gist.github.com/youxu71/f8abceb3587be04474ca0d0921195564)

Note:

1. Since the index was created by restoring the old ES 2.4 snapshot, you can see the "string" instead of "text" in mapping.
2. For some fields like Title, Description, we have multiple language specific fields to better support multi-lingual query, like Title\_english, Title\_german, etc.
3. We have nested fields to be used in nested function\_score with groovy script\_score:

```auto
{
"nested": {
	"path": "QueryClicks",
	"query": {
		"function_score": {
			"boost_mode": "replace",
			"query": {
				"match": {
					"QueryClicks.Term.lowercaseraw": "elasticsearch 5.2"
				}
			},
			"functions": [{
					"script_score": {
						"script": {
							"inline": "log(doc['QueryClicks.Count'].value*4)",
							"lang": "groovy"
						}
					}
				}
			]
		}
	}
}
}

```

More details, please refer to gist.

---

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [February 15, 2017, 4:58am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/7 "2017-02-15T04:58:04Z")

</div>

Does anyone encounter similar obvious query performance degradation after migrated to ES 5.2?

---

<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: [February 15, 2017, 10:34am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/8 "2017-02-15T10:34:09Z")

</div>

Could you also share the output of the profile API on that particular query? Ideally both with 2.4 and 5.2 so that we can compare.

---

<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: [February 16, 2017, 9:05am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/9 "2017-02-16T09:05:42Z")

</div>

For the record, there are sme known regressions between 1.x and 2.x but it is the first time I hear of a regression between 2.x and 5.x.

---

<div class="post-metadata">

### Author: ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)
#### Post date: [February 17, 2017, 1:06am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/10 "2017-02-17T01:06:10Z")

</div>

After investigation, the degradation might not be due to 5.2 migration. I am still investigating the root cause, and will get back to you with details.

Thanks your help!

---

<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: [March 17, 2017, 1:06am UTC](https://discuss.elastic.co/t/es-5-2-query-performance-much-worse-than-es-2-4/74990/11 "2017-03-17T01:06:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
