# Changing index.codec on existing index?

**URL:** <https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249>\
**Category:** Elasticsearch\
**Created:** [October 18, 2016, 6:06am UTC](https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249 "2016-10-18T06:06:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![german23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/german23/32/11052_2.png) [@german23](https://discuss.elastic.co/u/german23)\
**Post date:** [October 18, 2016, 6:06am UTC](https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249/1 "2016-10-18T06:06:49Z")

</div>

Hi,

i tried changing the index.codec on a existing index to "best\_compression"(DEFLATE) to achieve better compression values, than the standard LZ4.

I closed the index, changed the codec, reopened it and than run the optimize api on it with setting the max\_num\_segments to 20.

The index did have 998 GB (according to kopf-plugin), after the optimize command finished (took ages, somehow the merging from \_optmize only run with 20MB/s) the index still got 996 GB according to kopf.

Is it in the nature of ES that existing indices can not be compressed very good? Can i expect better resuls when setting index.codec at index creating time?

I am tryting to replace the compression of our filesystem with this, since the CPU overhead is quite large now and i think that the performance decrease from ES will not have that big of an impact.

Thanks for your response.

Regards

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 20, 2016, 2:43am UTC](https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249/2 "2016-10-20T02:43:04Z")

</div>

> [@german23](#):
>
> I closed the index, changed the codec, reopened it and than run the optimize api on it with setting the max\_num\_segments to 20.

Why not 1?

> [@german23](#):
>
> Is it in the nature of ES that existing indices can not be compressed very good?

Sparse values don't compress very well, so it could be that.

---

<div class="post-metadata">

**Author:** ![german23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/german23/32/11052_2.png) [@german23](https://discuss.elastic.co/u/german23)\
**Post date:** [October 20, 2016, 6:59am UTC](https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249/3 "2016-10-20T06:59:54Z")

</div>

> Why not 1?

I though reducing the number of segments from 943 to 320 would be enough to give me an idea of how the compression is going to work out (maybe it only comes into play if the segments get bigger, so less segments? )

Regardless of that, i am going to try out how the compression performs when setting it at index creation time

---

<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:** [October 20, 2016, 7:05am UTC](https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249/4 "2016-10-20T07:05:02Z")

</div>

What kind of data are you storing? Do you have`_source` enabled?

---

<div class="post-metadata">

**Author:** ![german23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/german23/32/11052_2.png) [@german23](https://discuss.elastic.co/u/german23)\
**Post date:** [October 20, 2016, 7:10am UTC](https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249/5 "2016-10-20T07:10:10Z")

</div>

\_source is enabled.

We use ES for logging, so the data mostly consist out of netflow data, windows event logs and unix like log files

---

<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:** [July 5, 2017, 10:11pm UTC](https://discuss.elastic.co/t/changing-index-codec-on-existing-index/63249/6 "2017-07-05T22:11:00Z")

</div>


