This topic explains how to optimize the performance of a CSS vector database from two aspects—write and query.
Optimizing Write Performance
Writing vector data incurs three major overheads: replica synchronization, index refresh, and segment merging. When index data is written in real time, frequent index refresh operations generate a large number of small segments. This triggers frequent vector index build and merge operations, which consume excessive CPU/IO resources. You can try the following solutions to optimize write performance.
Optimizing Query Performance
Query performance is affected by the following factors: the number of segments, the memory circuit breaker mechanism, and field recall. An excessively large number of segments impacts search efficiency; when off-heap memory becomes insufficient, vector index data is frequently swapped in and out of the memory; recalling all fields increases the load during the fetch phase. You can optimize query performance by addressing these factors.
Setting Cache Timeout
When the cluster's memory resources are insufficient, data is frequently updated, or high data freshness is required, you can enable automatic cache expiration to have inactive data cleared from the cache. This helps to optimize system performance, ensure data consistency, and improve query stability. Use this approach where data updates frequently or memory resources are stretching thin.
Run the following command to set cache timeout:
PUT _cluster/settings{"persistent": {"native.cache.expiry.enabled": "true","native.cache.expiry.time": "30m"}}
Parameter | Type | Description |
|---|---|---|
native.cache.expiry.enabled | Boolean | Whether to enable automatic cache expiration. Value range:
|
native.cache.expiry.time | String | Timeout of inactive cache items. This parameter takes effect only when native.cache.expiry.enabled=true. Value: a time string, for example, 24h (24 hours) or 30m (30 minutes). Default value: 24h. |