# Profiling query show shard latency

**URL:** <https://discuss.elastic.co/t/profiling-query-show-shard-latency/114123>\
**Category:** Elasticsearch\
**Created:** [January 4, 2018, 4:00pm UTC](https://discuss.elastic.co/t/profiling-query-show-shard-latency/114123 "2018-01-04T16:00:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcheronneau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tcheronneau/32/26248_2.png) [@tcheronneau](https://discuss.elastic.co/u/tcheronneau)\
**Post date:** [January 4, 2018, 4:00pm UTC](https://discuss.elastic.co/t/profiling-query-show-shard-latency/114123/1 "2018-01-04T16:00:55Z")

</div>

Hello everyone,

I'm facing a strange situation.  
I'm trying to optimize a cluster of elasticsearch and during my research I tried the search profiler.  
Here is my query :  
{  
"query":{  
"regexp" : {  
"host":"myhost.\*"  
}  
}  
}

It's a really simple query the purpose was to get first results.  
But the query profile showed me that shards are not giving the same response time.  
Example :  
2.423s [shard][1]  
2.414s [shard][0]  
2.369s [shard][4]  
2.305s [shard][2]  
157.583ms [shard][3]

On the second time I profile the query I'll get :  
2.927s [shard][4]  
2.719s [shard\_dsyQfrR70A][3]  
2.161s [shard][2]  
179.997ms [shard][1]  
165.359ms [shard][0]

On the third time I run the profile the result will be similar to the first, then to the second and so on... (the pattern is based on the shards number).  
I really don't understand why this is appenning but this is a pattern I see on both our cluster.

For information there is 3 nodes (identical in version 5.6) and shards are separate on the 3 nodes.  
Does anyone already have this kind of comportement ?

Thanks,  
Thomas.

---

<div class="post-metadata">

**Author:** ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)\
**Post date:** [January 12, 2018, 9:15am UTC](https://discuss.elastic.co/t/profiling-query-show-shard-latency/114123/2 "2018-01-12T09:15:14Z")

</div>

you can use a [preference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-preference.html) to get more stable results. I assume that is might depend on which replica you are hitting but I am not 100% sure

---

<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 9, 2018, 9:15am UTC](https://discuss.elastic.co/t/profiling-query-show-shard-latency/114123/3 "2018-02-09T09:15:43Z")

</div>

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