# Changing compression type in rocksdb | percona mysql

**URL:** <https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260>\
**Category:** Percona Server for MySQL\
**Tags:** myrocks\
**Created:** [October 9, 2024, 1:32pm UTC](https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260 "2024-10-09T13:32:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathava\_Selvan](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mathava\_Selvan](https://forums.percona.com/u/Mathava_Selvan)\
**Post date:** [October 9, 2024, 1:32pm UTC](https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260/1 "2024-10-09T13:32:27Z")

</div>

Looking for guidance for CompressionType for rocksdb storage engine in percona mysql

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 9, 2024, 4:11pm UTC](https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260/2 "2024-10-09T16:11:28Z")

</div>

> [@Mathava\_Selvan](#):
>
> CompressionType

> **[Percona Server for MySQL - MyRocks column families](https://docs.percona.com/percona-server/8.0/myrocks-column-family.html)**
>
> MyRocks stores all data in a single server instance as a collection of
> key-value pairs within the log structured merge tree data structure. This is a
> flat data structure that requires that keys be unique throughout the whole data
> structure. MyRocks...

Have a look at the default value for `rocksdb_default_cf_options` [MyRocks server variables - Percona Server for MySQL](https://docs.percona.com/percona-server/8.0/variables.html#rocksdb_default_cf_options)

Compare that to this options string, which comes from another consultant on his view of best options for MyRocks:

```auto
rocksdb_default_cf_options=write_buffer_size=256m;target_file_size_base=32m;max_bytes_for_level_base=512m;level0_file_num_compaction_trigger=4;level0_slowdown_writes_trigger=10;level0_stop_writes_trigger=15;max_write_buffer_number=4;compression_per_level=kLZ4Compression;bottommost_compression=kZSTD;compression_opts=-14:3:0:32768:327680;block_based_table_factory={cache_index_and_filter_blocks=1;filter_policy=bloomfilter:10:false;whole_key_filtering=1};level_compaction_dynamic_level_bytes=true;optimize_filters_for_hits=true;compaction_pri=kMinOverlappingRatio;memtable_prefix_bloom_size_ratio=0.05;prefix_extractor=capped:36

```

---

<div class="post-metadata">

**Author:** ![Mathava\_Selvan](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mathava\_Selvan](https://forums.percona.com/u/Mathava_Selvan)\
**Post date:** [October 10, 2024, 5:39am UTC](https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260/3 "2024-10-10T05:39:36Z")

</div>

Thanks, I will be grateful if you share the documentation link to the different types of compression in the RocksDB storage engine and a guide on how to change compression at the table level and globally.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 10, 2024, 1:27pm UTC](https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260/4 "2024-10-10T13:27:44Z")

</div>

@Mathava_Selvan, I did. See my link above. You can’t change MyRocks compression on a per-table basis. It can only be done on a per-column family basis as the docs I linked above explain.

---

<div class="post-metadata">

**Author:** ![Mathava\_Selvan](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mathava\_Selvan](https://forums.percona.com/u/Mathava_Selvan)\
**Post date:** [October 11, 2024, 6:46pm UTC](https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260/5 "2024-10-11T18:46:19Z")

</div>

Thanks , Really helps.

I am trying to find possible values for `compression_per_level`, `bottommost_compression`, and `compaction_pri` for the `rocksdb_default_cf_options` variable, but I am unable to find them. Could someone please help with this?

Note: The goal is to reduce the table size with the help of the RocksDB storage engine. Please advise if any relevant settings would have an impact.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 21, 2024, 3:49pm UTC](https://forums.percona.com/t/changing-compression-type-in-rocksdb-percona-mysql/34260/6 "2024-10-21T15:49:54Z")

</div>

This is what I found:

> <https://github.com/facebook/rocksdb/blob/c0be6a4b90a1f616969b2a808035ebf334894a37/include/rocksdb/compression_type.h#L18>

I would stick with ZSTD. It’s fast and has excellent compression and is the most modern of the compression options. This is what is used in the config I provided earlier.
