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 allocated to vector indexes by using the ob_vector_memory_limit_percentage parameter:
Before you use HNSW/HNSW_SQ/HNSW_BQ vector indexes in versions earlier than V4.4.1, you must manually set
ob_vector_memory_limit_percentageto enable vector search. We recommend that you set it to30for optimal search performance. If you do not set this parameter, no memory is allocated to vector indexes, and an error is returned when you create an index. Here is an example:ALTER SYSTEM SET ob_vector_memory_limit_percentage = 30;Starting from V4.4.1, vector search is enabled by default. The default value of
0indicates adaptive mode, where the system automatically adjusts the memory allocation for vector indexes in the tenant without manual intervention:- If the actual memory of the tenant is 8 GB or less, the value is automatically set to
40. - If the actual memory of the tenant is more than 8 GB, the value is automatically set to
50.
- If the actual memory of the tenant is 8 GB or less, the value is automatically set to
Query index memory estimation and actual usage
You can use the DBMS_VECTOR system package to estimate index memory:
- Before you create a table, you can call the INDEX_VECTOR_MEMORY_ADVISOR procedure to estimate index memory.
- After you create a table and insert data, you can call the INDEX_VECTOR_MEMORY_ESTIMATE procedure to analyze index memory.
The vector index memory estimation returns two pieces of information: the minimum memory configuration required to create a vector index and the actual memory usage after the creation of HNSW_SQ and IVF indexes.
You can query the GV$OB_VECTOR_MEMORY or V$OB_VECTOR_MEMORY view to obtain detailed information about the actual memory usage.
Memory optimization for index rebuilds
For partitioned tables, we also provide the vector_index_memory_saving_mode parameter to control the memory usage during index rebuilds. Enabling this mode reduces the memory consumption during the rebuild process of vector indexes in partitioned tables. Typically, vector index rebuilds require twice the memory of the index. When this mode is enabled, the system temporarily deletes the memory index of each partition after it is built to free up memory, effectively reducing the total memory required for the rebuild. For syntax and examples, see vector_index_memory_saving_mode.