简体中文
Appearance
简体中文
Appearance
在查询过程中,系统需要从存储引擎读取索引数据以进行查询优化。频繁的磁盘I/O操作会增加查询延迟和系统开销。通过将索引数据缓存在内存中,可以显著减少磁盘访问次数,从而提升查询性能。
如果系统内存充足,建议将所有索引数据加载到缓存中。配置缓存大小时,通常设置为存储文件总大小的2%左右。
在实际生产环境中,通常只需缓存热数据(高频访问的数据,如最近7天的数据)的索引。可根据热数据量估算所需缓存大小。当缓存空间不足时,系统会基于LFU(最近最少使用)策略自动淘汰不常用的索引数据。
修改Datalayers配置文件(默认路径:/etc/datalayers/datalayers.toml)中的以下参数:
[ts_engine]
# Cache size for SST file metadata. Setting it to 0 to disable the cache.
# Default: 128M
meta_cache_size = "256M"
# Whether or not to preload parquet metadata on startup.
# This config only takes effect if the `ts_engine.meta_cache_size` is greater than 0.
# Default: true.
preload_parquet_metadata = true可通过 Datalayers 提供的指标看板观察缓存命中率情况,结合业务需求进行调优。