# Clear Cache After Bulk Insertion

**URL:** <https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081>\
**Category:** Elasticsearch\
**Created:** [December 11, 2017, 12:11pm UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081 "2017-12-11T12:11:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shemilr](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shemilr](https://discuss.elastic.co/u/shemilr)\
**Post date:** [December 11, 2017, 12:11pm UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/1 "2017-12-11T12:11:49Z")

</div>

I am creating index which have 1 million data. I have many indexes with similar size. After creatng some indexes, this bulk insertion is too slow. If we are restarting the elasticsearch service in server, insert will be fast.

Is there any cache for this bulk insertion? so that I can clear this cache. I tried the flush and clearcache functions. But no luck.

I am using elasticsearch 5.6.3 versiona nd php sdk 5.

Anyone have the same issue? What is the best solution of this issue?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 11, 2017, 2:21pm UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/2 "2017-12-11T14:21:46Z")

</div>

> Anyone have the same issue?

When I'm doing that, I have a constant injection rate.

> What is the best solution of this issue?

Check your code. Check the logs and see if you have some GC problems...

---

<div class="post-metadata">

**Author:** ![shemilr](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shemilr](https://discuss.elastic.co/u/shemilr)\
**Post date:** [December 12, 2017, 4:25am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/3 "2017-12-12T04:25:22Z")

</div>

But my doubt is that, when I am restarting the elasticsearch service insertion is becoming fast. After some insertion its getting delayed. Thats why I am doubtful about the cache.

I am inserting 11K records per request.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 12, 2017, 6:12am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/4 "2017-12-12T06:12:21Z")

</div>

There is no bulk cache.

---

<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:** [December 12, 2017, 6:36am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/5 "2017-12-12T06:36:56Z")

</div>

How much heap do you have? What is the size of your documents? Have you tried with smaller bulk requests?

---

<div class="post-metadata">

**Author:** ![shemilr](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shemilr](https://discuss.elastic.co/u/shemilr)\
**Post date:** [December 12, 2017, 7:23am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/6 "2017-12-12T07:23:55Z")

</div>

I am inserting 11k documents at a time. This index itself having 150K data (around 266MB).

If I am inserting after the elasticsearch servoce restart, index will create with in 1.3 minutes. But after creating some other indexes in I am deleting anad recreating the same index it will take more than 6 minutes.

This is the result of " /\_nodes/stats "

```auto
{"heap_used_in_bytes":1659868400,"heap_used_percent":79,"heap_committed_in_bytes":2075918336,"heap_max_in_bytes":2075918336,"non_heap_used_in_bytes":135452384,"non_heap_committed_in_bytes":143286272,"

```

---

<div class="post-metadata">

**Author:** ![shemilr](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shemilr](https://discuss.elastic.co/u/shemilr)\
**Post date:** [December 12, 2017, 7:30am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/7 "2017-12-12T07:30:43Z")

</div>

Do we need to set separate heap size for ES ? can you share the syntax for that ?

---

<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:** [December 12, 2017, 7:33am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/8 "2017-12-12T07:33:21Z")

</div>

You can set the heap size in the `jvm.options` configuration file.

---

<div class="post-metadata">

**Author:** ![shemilr](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@shemilr](https://discuss.elastic.co/u/shemilr)\
**Post date:** [December 12, 2017, 11:07am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/9 "2017-12-12T11:07:21Z")

</div>

I increased the heap size and now it seems fine.

Thank you for the support.

---

<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:** [January 9, 2018, 11:07am UTC](https://discuss.elastic.co/t/clear-cache-after-bulk-insertion/111081/10 "2018-01-09T11:07:55Z")

</div>

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