# Latency Spike now and then even though the query is simple

**URL:** <https://discuss.elastic.co/t/latency-spike-now-and-then-even-though-the-query-is-simple/133262>\
**Category:** Elasticsearch\
**Created:** [May 25, 2018, 6:29am UTC](https://discuss.elastic.co/t/latency-spike-now-and-then-even-though-the-query-is-simple/133262 "2018-05-25T06:29:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![owenericsson](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@owenericsson](https://discuss.elastic.co/u/owenericsson)\
**Post date:** [May 25, 2018, 6:29am UTC](https://discuss.elastic.co/t/latency-spike-now-and-then-even-though-the-query-is-simple/133262/1 "2018-05-25T06:29:29Z")

</div>

hi

recently i am suffered with this problem while i am using an index and here is a summary of this index  
ES: 5.5.2  
docs: ~1 billion  
shards: 3  
indexing rate: \< 100 TPS  
structure: simple, long/keyword/date  
query: simple, 99.99% just do a terms query on \_id, and here is an template example

==========

> ```
> {
> "size": {{size}}{{^size}}300{{/size}},
> "query": {
> "bool": {
> "filter": [{
> "terms": {
> "_id": {{#toJson}}array.list{{/toJson}}
> }
> },
> {"script": {
> "script": {
> "lang": "painless",
> "params": {
> "now": {{now}}{{^now}}null{{/now}}
> },
> "inline": "def now = params.now; if (now == null) { def d = new Date(); now = d.getTime(); } now+=28800000; return doc['time_from'].value > now && doc['status'].value==1;"
> }
> }
> }
> ]
> }
> }    
> }
> 
> ```

========

i already noticed that there is a question on this topic( [Latency spike after big merge](https://discuss.elastic.co/t/latency-spike-after-big-merge/124290)), however mine is a little bit different. because i do want to have a range query to avoid this problem, but the result still make me upset, the latency spike still happened.

the result is:  
99% of the queries return within 5ms however still some latency queries return at around 200 ~ 1000 ms. the only suspect i guess is still related with the lucene merges.

do you think so ?

---

<div class="post-metadata">

**Author:** ![owenericsson](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@owenericsson](https://discuss.elastic.co/u/owenericsson)\
**Post date:** [May 29, 2018, 10:36am UTC](https://discuss.elastic.co/t/latency-spike-now-and-then-even-though-the-query-is-simple/133262/2 "2018-05-29T10:36:10Z")

</div>

somebody could give a hint ?

---

<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:** [June 26, 2018, 10:36am UTC](https://discuss.elastic.co/t/latency-spike-now-and-then-even-though-the-query-is-simple/133262/3 "2018-06-26T10:36:20Z")

</div>

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