# Regarding index.codec

**URL:** <https://discuss.elastic.co/t/regarding-index-codec/319975>\
**Category:** Elasticsearch\
**Created:** [November 28, 2022, 7:44pm UTC](https://discuss.elastic.co/t/regarding-index-codec/319975 "2022-11-28T19:44:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![prat1](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@prat1](https://discuss.elastic.co/u/prat1)\
**Post date:** [November 28, 2022, 7:44pm UTC](https://discuss.elastic.co/t/regarding-index-codec/319975/1 "2022-11-28T19:44:26Z")

</div>

Hi Team,

Regarding compression in documentation it is mentioned as below,

### 

Use `best_compression`

The `_source` and stored fields can easily take a non negligible amount of disk space. They can be compressed more aggressively by using the `best_compression` [codec](https://www.elastic.co/guide/en/elasticsearch/reference/7.16/index-modules.html#index-codec).

Q. Is the compression only applies to `_source` and `stored` fields and not on `indexed` fields?

As we know, by default, not all fields are stored and as per above statement, only `_source` and `stored` fields are compressed.

I am interested to know, is applying compression affects overall elasticsearch performance if its use case is searching data, running aggregation, running query etc..

Can we conclude that applying compression has no effect on query or aggregation performance as query and aggregation will be performed on indexed fields and not on \_source fields.

Thanks,

---

<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:** [November 29, 2022, 1:11am UTC](https://discuss.elastic.co/t/regarding-index-codec/319975/2 "2022-11-29T01:11:47Z")

</div>

It will have an impact as there is more CPU needed to decompress the data.

What that impact looks like will need testing based on your hardware, data and setup.

---

<div class="post-metadata">

**Author:** ![prat1](https://avatars.discourse-cdn.com/v4/letter/p/ccd318/32.png) [@prat1](https://discuss.elastic.co/u/prat1)\
**Post date:** [November 29, 2022, 6:06am UTC](https://discuss.elastic.co/t/regarding-index-codec/319975/3 "2022-11-29T06:06:33Z")

</div>

It needs CPU to decompress data but only on \_source and stored fields right and not on indexed fields. As i said, not all fields are stored by default.

My question is about the indexed fields as on these fields we run queries, aggregation etc.. so does compression affects query performance any way?

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:** [November 29, 2022, 6:09am UTC](https://discuss.elastic.co/t/regarding-index-codec/319975/4 "2022-11-29T06:09:31Z")

</div>

I believe using the best\_compression codec primarily adds load at indexing time. It does not affect queries much.

---

<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:** [December 27, 2022, 6:10am UTC](https://discuss.elastic.co/t/regarding-index-codec/319975/5 "2022-12-27T06:10:22Z")

</div>

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