向量检索的性能调优 本章节主要介绍向量检索的性能调优。 写入性能优化 关闭副本,待数据导入完成后再开启副本,减少副本构建的开销。 调整“refreshinterval”为120s或者更大,避免频繁刷新索引生成大量小的segments,同时减少merge带来的向量索引构建开销。 适当调大“native.vector.indexthreads”的值(默认为4),增加向量索引构建的线程数。 PUT cluster/settings { "persistent": { "native.vector.indexthreads": 8 } } 查询性能优化 在批量导入场景下,数据写入完成后,执行forcemerge操作能有效提升查询效率。 POST indexname/forcemerge?maxnumsegments1 如果向量索引所需外内存超过了熔断线,查询时索引的缓存管理器会控制索引的换进换出,导致查询变慢,此时可适当调大熔断线的配置。 PUT cluster/settings { "persistent": { "native.cache.circuitbreaker.cpu.limit": "75%" } } 如果端到端时延明显大于返回结果中的took值,说明查询的fetch阶段开销较大,可通过配置“source”减小fdt文件的大小,从而降低fetch开销。 PUT myindex { "settings": { "index": { "vector": "true" }, "index.softdeletes.enabled": false }, "mappings": { "source": { "excludes": ["myvector"] }, "properties": { "myvector": { "type": "vector", "dimension": 128, "indexing": true, "algorithm": "GRAPH", "metric": "euclidean" } } } }