更详细可以参考代码 db_options_type_info
以下参数是column family级别的,可以分别对每个column family设置
参数 | 说明 | 备注 |
writebuffer_size | memtable内存大小 | 默认 |
max_write_buffer_number | memtable的最大个数 | 默认2 |
min_write_buffer_number_to_merge | it is the minimum number of memtables to be merged before flushing to storage. For example, if this option is set to 2, immutable memtables are only flushed when there are two of them | 默认1 |
target_file_size_base | level1 sst大小 | 默认64M |
target_file_size_multiplier | level L(L>1) sst大小 target_file_size_base (target_file_size_multiplier ^ (L-1)) | 默认1, For example, if target_file_size_base is 2MB and target_file_size_multiplier is 10, then each file on level-1 will be 2MB, and each file on level-2 will be 20MB, and each file on level-3 will be 200MB |
max_bytes_for_level_base | level1的sst总大小 | 默认256M |
max_bytes_for_level_multiplier | level L的sst总大小为 max_bytes_for_level_base(max_bytes_for_level_multiplier)^(L-1))*max_bytes_for_level_multiplier_additional(L-1) (VersionStorageInfo::CalculateBaseBytes) | 默认10 |
max_bytes_for_level_multiplier_additional | Different max-size multipliers for different levels. (VersionStorageInfo::CalculateBaseBytes) | 默认:1:1:1:1:1:1:1 |
num_levels | level数量 | 默认7 |
level0_file_num_compaction_trigger | 当level0文件数量超过此值时触发level0 compact | 默认4 |
level0_slowdown_writes_trigger | 当level0文件数量超过此值时触发x写delay | 默认20 |
level0_stop_writes_trigger | 当level0文件数量超过此值时触发停写 | 默认36 |
pin_l0_filter_and_index_blocks_in_cache | if cache_index_and_filter_blocks is true and the below is true, then filter and index blocks are stored in the cache, but a reference is held in the “table reader” object so the blocks are pinned and only evicted from cache when the table reader is freed. | 默认1, column family单独设置会覆盖rocksdb_pin_l0_filter_and_index_blocks_in_cache |
cache_index_and_filter_blocks | index和filter blocks是否缓存到block cache | 默认1, column family单独设置会覆盖rocksdb_cache_index_and_filter_blocks |
optimize_filters_for_hits | 设置为True, 最后一层不保存filter信息,最后一层bloomfilter实际没有用处 | 默认OFF |
filter_policy | 指定filter策略 | filter_policy=bloomfilter:10:false 表示使用bloomfilter, bits_per_key=10, hash函数个数为10*ln2, false:useblock_based_builder=false,表示使用full filter |
prefixextractor | 指定filter使用前缀 | prefix_extractor=capped:24表示最多取前缀24个字节,另外还有fixed:n方式表示只取前缀n个字节,忽略小于n个字节的key. 具体可参考CappedPrefixTransform,FixedPrefixTransform |
partition_filters | 表示时否使用partitioned filter | 默认false filter 参数优先级如下 block base > partitioned > full. 比如说同时指定use_block_based_builder=true和partition_filters=true实际使用的block based filter |
whole_key_filtering | If true, place whole keys in the filter (not just prefixes) | 默认1 |
level_compaction_dynamic_level_bytes | In this mode, size target of levels are changed dynamically based on size of the last level. 减少写放大 | |
memtable | 指定memtable类型(skiplist/vector/hash_linkedlist/prefix_hash/cuckoo) | 默认skiplist |
compaction_pri | compact选择文件策略 kByCompensatedSize: Slightly prioritize larger files by size compensated by #deletes kOldestLargestSeqFirst: First compact files whose data’s latest update time is oldest kOldestSmallestSeqFirst: First compact files whose range hasn’t been compacted to the next level for the longest kMinOverlappingRatio: First compact files whose ratio between overlapping size in next level and its size is the smallest | 默认kByCompensatedSize |
compression_per_level | 指定每个level的压缩策略 | It usually makes sense to avoid compressing levels 0 and 1 and to compress data only in higher levels. You can even set slower compression in highest level and faster compression in lower levels (by highest we mean Lmax). |
bottommost_compression | 指定最底level的压缩策略 | |
arena_block_size | rocksdb内存分配单位KBlockSize由参数arena_block_size指定 | arena_block_size不指定时默认为write_buffer_size的1/8. |
soft_pending_compaction_bytes_limit | All writes will be slowed down to at least delayed_write_rate if estimated bytes needed to be compaction exceed this threshold | 默认64G |
hard_pending_compaction_bytes_limit | All writes are stopped if estimated bytes needed to be compaction exceed this threshold. | 默认256G |
更详细可以参考代码ParseColumnFamilyOption, cf_options_type_info
参数修改示例