# Insert/Update operations makes queries slow?

**URL:** <https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105>\
**Category:** Elasticsearch\
**Created:** [July 5, 2019, 12:55pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105 "2019-07-05T12:55:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JF2018](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@JF2018](https://discuss.elastic.co/u/JF2018)\
**Post date:** [July 5, 2019, 12:55pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105/1 "2019-07-05T12:55:34Z")

</div>

Hi

I am using elastic 1.7 (I know I should update, but it is currently not possible)

I have an index with the following setup:

- ~70GB,
- 4 shards
- 2 replica
- 1756260 documents

I have an ingestor, which inserts/updates ~25 documents/min - primarily updates.  
When the ingestor is running queries takes ~5000ms, while they only take ~300ms when its not.

The refresh interval for the index is 30s.  
It is only queries to the specific index (we have multiple other indices on the same nodes) which becomes slow.

My understanding of updates is, they delete and insert again, since documents are immutable.  
But does it also do something else, which should influence the query time?  
Like taking locks on shards or similar?

Hope someone can help, thanks.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 5, 2019, 1:09pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105/2 "2019-07-05T13:09:08Z")

</div>

What is leading to the increased latency? Increased CPU usage? Additional disk I/O? Increased iowait?

---

<div class="post-metadata">

**Author:** ![JF2018](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@JF2018](https://discuss.elastic.co/u/JF2018)\
**Post date:** [July 5, 2019, 1:28pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105/3 "2019-07-05T13:28:35Z")

</div>

I have not registered any significant increase in CPU usage or disk I/O.  
For the IOWait, there is a small increase in WritingIOWait, but not something which seems significant, and I would not expect it to influence queries, which are purely read. I would also expect queries to my other indices on the same nodes, to take longer time, if iowait was the reason - but I could very well be wrong 🙂

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 5, 2019, 1:58pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105/4 "2019-07-05T13:58:09Z")

</div>

Then it is probably cache related. Writing or updating documents will affect caching.

---

<div class="post-metadata">

**Author:** ![JF2018](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@JF2018](https://discuss.elastic.co/u/JF2018)\
**Post date:** [July 5, 2019, 1:59pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105/5 "2019-07-05T13:59:53Z")

</div>

But is the refresh interval not the way to control that?

---

<div class="post-metadata">

**Author:** ![JF2018](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@JF2018](https://discuss.elastic.co/u/JF2018)\
**Post date:** [July 24, 2019, 12:09pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105/6 "2019-07-24T12:09:31Z")

</div>

For future reference:

I narrowed the problem down to queries with aggregations.  
The solution to my problem is mentioned here:

> [@Aggregations slow after inserts/updates](https://discuss.elastic.co/t/aggregations-slow-after-inserts-updates/191352/2):
>
> What kind of hardware do you have? Are you using doc\_values? Can you upgrade? We are now on 7.2 and so many things happened in the last 3 or 4 years... Including in the JVM itself.

---

<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:** [August 21, 2019, 12:13pm UTC](https://discuss.elastic.co/t/insert-update-operations-makes-queries-slow/189105/7 "2019-08-21T12:13:21Z")

</div>

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