MyRocks config compaction readahead size

As I can see from MyRocks Server Variables:

variable rocksdb_compaction_readahead_sizeSpecifies the size of reads to perform ahead of compaction.
Default value is 0.
Set this to at least 2 megabytes (16777216)
when using MyRocks with spinning disks
to ensure sequential reads instead of random.
Maximum allowed value is 18446744073709551615.


If you set this variable to a non-zero value, rocksdb_new_table_reader_for_compaction_inputs is enabled.

So my questions is if I understand correctly when rocksdb_compaction_readahead_size specified with non zero value I need to enable rocksdb_new_table_reader_for_compaction_inputs or it will be enabled automatically?



When rocksdb_compaction_readahead_size is set to a value greater than 0, then rocksdb_new_table_reader_for_compaction_inputs is going to be set to true automatically. However, it’s important to notice that this override happens not on MySQL level, so you’ll see rocksdb_new_table_reader_for_compaction_inputs=0 when rocksdb_compaction_readahead_size=16777216, for example. This override will happen inside RocksDB. Thus, I would recommend that you set rocksdb_new_table_reader_for_compaction_inputs to 1 for clarity when using compaction readahead.

See rocksdb sources for reference. You can also note that use_direct_reads=1 will also enable rocksdb_new_table_reader_for_compaction_inputs, and, unless that parameter is explicitly set, will also set rocksdb_compaction_readahead_size to 2097152.

Again, since this happens so far under the hood that there’s currently no way to see the actual values, I would recommend to initialize variables explicitly.

Hope this helps.