This topic describes how to estimate and manage the memory usage of vector indexes in OceanBase Database.
Configure vector index memory
OceanBase Database allows you to configure the memory usage of vector indexes by setting the ob_vector_memory_limit_percentage parameter:
For OceanBase Database V4.3.5 BP3 and earlier: Before using HNSW, HNSW_SQ, or HNSW_BQ vector indexes, you must manually set the
ob_vector_memory_limit_percentageparameter to enable vector search. We recommend setting this parameter to30for optimal search performance. If you do not set this parameter, no memory is allocated to vector indexes, and index creation will return an error. IVF and IVF_PQ indexes do not require resident memory, so this parameter does not apply to them. Example:ALTER SYSTEM SET ob_vector_memory_limit_percentage = 30;Starting from OceanBase Database V4.3.5 BP3: Vector search is enabled by default. The default value of
0enables adaptive mode, where the system automatically adjusts the memory usage ratio for vector indexes within the tenant, requiring no manual intervention:- If the tenant's available memory is 8 GB or less, the value automatically adjusts to
40. - If the tenant's available memory is more than 8 GB, the value automatically adjusts to
50.
- If the tenant's available memory is 8 GB or less, the value automatically adjusts to
Estimate and query index memory usage
You can use the DBMS_VECTOR system package to estimate the memory usage of vector indexes:
- Before creating a table, use the INDEX_VECTOR_MEMORY_ADVISOR procedure to estimate the required memory.
- After creating a table and inserting data, use the INDEX_VECTOR_MEMORY_ESTIMATE procedure to analyze actual memory usage.
Memory estimation returns two pieces of information: the minimum memory configuration required to create vector indexes, and the actual memory usage after creating HNSW_SQ and IVF indexes.
Controll memory index loading
The load_vector_index_on_follower parameter controls whether memory vector indexes are automatically loaded on follower nodes. For details and examples, see load_vector_index_on_follower. If you do not need weak reads, you can disable this parameter to reduce memory usage.
Optimize memory usage during index rebuild
For partitioned tables, the vector_index_memory_saving_mode parameter controls memory usage during index rebuilds. Enabling this mode reduces memory consumption when rebuilding vector indexes on partitioned tables. Typically, rebuilding a vector index consumes twice the index’s memory. With memory-saving mode enabled, the system temporarily deletes the memory index for each partition after it’s built, releasing memory and effectively reducing the total required for the rebuild. For more information, see vector_index_memory_saving_mode.