diff --git a/src/database/engine/cf_opts.rs b/src/database/engine/cf_opts.rs index 8cb659ac..158fb3c8 100644 --- a/src/database/engine/cf_opts.rs +++ b/src/database/engine/cf_opts.rs @@ -1,8 +1,4 @@ -use conduwuit::{ - err, - utils::{math::Expected, BoolExt}, - Config, Result, -}; +use conduwuit::{err, utils::math::Expected, Config, Result}; use rocksdb::{ BlockBasedIndexType, BlockBasedOptions, BlockBasedPinningTier, Cache, DBCompressionType as CompressionType, DataBlockIndexType, LruCacheOptions, Options, @@ -133,10 +129,12 @@ fn table_options(desc: &Descriptor, has_cache: bool) -> BlockBasedOptions { opts.set_partition_filters(true); opts.set_use_delta_encoding(false); opts.set_index_type(BlockBasedIndexType::TwoLevelIndexSearch); - opts.set_data_block_index_type( - desc.block_index_hashing - .map_or(DataBlockIndexType::BinarySearch, || DataBlockIndexType::BinaryAndHash), - ); + + opts.set_data_block_index_type(match desc.block_index_hashing { + | None if desc.index_size > 512 => DataBlockIndexType::BinaryAndHash, + | Some(enable) if enable => DataBlockIndexType::BinaryAndHash, + | Some(_) | None => DataBlockIndexType::BinarySearch, + }); opts } diff --git a/src/database/engine/descriptor.rs b/src/database/engine/descriptor.rs index 06e1a29b..d668862b 100644 --- a/src/database/engine/descriptor.rs +++ b/src/database/engine/descriptor.rs @@ -34,7 +34,7 @@ pub(crate) struct Descriptor { pub(crate) compression: CompressionType, pub(crate) compression_level: i32, pub(crate) bottommost_level: Option, - pub(crate) block_index_hashing: bool, + pub(crate) block_index_hashing: Option, pub(crate) cache_shards: u32, } @@ -60,7 +60,7 @@ pub(crate) static BASE: Descriptor = Descriptor { compression: CompressionType::Zstd, compression_level: 32767, bottommost_level: Some(32767), - block_index_hashing: false, + block_index_hashing: None, cache_shards: 64, }; @@ -96,5 +96,6 @@ pub(crate) static SEQUENTIAL_SMALL: Descriptor = Descriptor { file_size: 1024 * 512, block_size: 512, cache_shards: 64, + block_index_hashing: Some(false), ..SEQUENTIAL };