# Elasticsearch Intermittent slow query

**URL:** <https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237>\
**Category:** Elasticsearch\
**Created:** [January 5, 2018, 8:47am UTC](https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237 "2018-01-05T08:47:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wang\_Jnercy](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@wang\_Jnercy](https://discuss.elastic.co/u/wang_Jnercy)\
**Post date:** [January 5, 2018, 8:47am UTC](https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237/1 "2018-01-05T08:47:20Z")

</div>

Online environment Documents: 394.9k Data: 242.9 MB of elasticsearch-version:5.4.0  
There will be a few full queries every hour, and the following is a slow query  
took[615.1ms], took\_millis[615], types[driverAsso], stats[], search\_type[QUERY\_THEN\_FETCH], total\_shards[5], source[{"size":0,"query":{"term":{"\_id":{"value":"97230938609757053:97230938609757073","boost":1.0}}}}],  
[![](https://user-images.githubusercontent.com/16145081/34599628-5ebbd1aa-f22e-11e7-995b-3ad23d669de8.png) ](https://user-images.githubusercontent.com/16145081/34599628-5ebbd1aa-f22e-11e7-995b-3ad23d669de8.png)  
[![](https://user-images.githubusercontent.com/16145081/34599641-6ce5b8ae-f22e-11e7-8c02-b82dcd4c8036.png) ](https://user-images.githubusercontent.com/16145081/34599641-6ce5b8ae-f22e-11e7-8c02-b82dcd4c8036.png)  
[![](https://user-images.githubusercontent.com/16145081/34599668-9332c1f0-f22e-11e7-84ae-0732c6a75117.png) ](https://user-images.githubusercontent.com/16145081/34599668-9332c1f0-f22e-11e7-84ae-0732c6a75117.png)  
Please help to analyze the reasons. Thank you

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [January 7, 2018, 4:22pm UTC](https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237/2 "2018-01-07T16:22:20Z")

</div>

If you have X-Pack installed then you can use Kibana's Search Profile to better understand the timings of your query. You can access it by going into Kibana Dev Tools.

But I can already tell you that with such small index there is no need to use 5 shards. Try using 1 shard and see if it gets better (there is an added overhead with multiple shards that might not be paying off)

---

<div class="post-metadata">

**Author:** ![wang\_Jnercy](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@wang\_Jnercy](https://discuss.elastic.co/u/wang_Jnercy)\
**Post date:** [January 8, 2018, 6:29am UTC](https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237/3 "2018-01-08T06:29:46Z")

</div>

The cluster configuration of our production environment will continue to have intermittent slow queries

 ![58](https://us1.discourse-cdn.com/elastic/original/3X/7/a/7a8fbfb1a8ab695bd8171358c13c38732dceb531.png) ![31](https://us1.discourse-cdn.com/elastic/original/3X/f/b/fb535efc134294bf47f5692de64311521fea9776.png)

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [January 8, 2018, 6:46am UTC](https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237/4 "2018-01-08T06:46:13Z")

</div>

As I said before, the best way to start debugging performance issue with queries is using the Profiler in Kibana's Dev Tool

---

<div class="post-metadata">

**Author:** ![wang\_Jnercy](https://avatars.discourse-cdn.com/v4/letter/w/f04885/32.png) [@wang\_Jnercy](https://discuss.elastic.co/u/wang_Jnercy)\
**Post date:** [January 10, 2018, 8:16am UTC](https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237/5 "2018-01-10T08:16:18Z")

</div>

![43](https://us1.discourse-cdn.com/elastic/original/3X/f/a/faaff6cf9d599ce70417991ff37456ceefb9f49b.png)  
I used constant\_socre when debugging and found that build\_scorer consumed a lot of time. What's the problem, thank you

---

<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:** [February 7, 2018, 8:16am UTC](https://discuss.elastic.co/t/elasticsearch-intermittent-slow-query/114237/6 "2018-02-07T08:16:26Z")

</div>

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