This topic describes how to estimate and manage the memory usage of all types of vector indexes in OceanBase AI Database.
Configure vector index memory
In OceanBase AI Database, you can set the ob_vector_memory_limit_percentage parameter to configure the memory for vector indexes:
The default value of this parameter is 0, which indicates adaptive mode. In adaptive mode, the system automatically adjusts the memory usage of vector index data in an instance without manual intervention:
- When the actual memory of an instance is 8 GB or less, this value adapts to
40. - When the actual memory of an instance is more than 8 GB, this value adapts to
50.
Estimate and query index memory usage
You can use the DBMS_VECTOR system package to estimate index memory usage:
- Before you create a table, you can call the INDEX_VECTOR_MEMORY_ADVISOR procedure to estimate the memory usage of indexes.
- After you create a table and insert data into it, you can call the INDEX_VECTOR_MEMORY_ESTIMATE procedure to analyze the memory usage of indexes.
Vector index memory estimation returns two pieces of information: the minimum memory configuration required to create the vector index, and the actual memory usage after the HNSW_SQ and IVF indexes are created.
Notice
For sparse indexes:
- The
IDX_TYPEparameter must be set toSINDIorSINDI_SQ(case-insensitive). - The memory usage of sparse vectors depends on the average length of sparse vectors, which is the average number of non-zero dimensions per vector.
You can query the GV$OB_VECTOR_MEMORY or V$OB_VECTOR_MEMORY view to obtain detailed information about the actual memory usage.
Optimize memory usage during index rebuild
For the vector index rebuild operation on a partitioned table, you can also use the vector_index_memory_saving_mode parameter to control the memory usage during index rebuild. Enabling this mode can reduce the memory consumption during the rebuild of a vector index on a partitioned table. Typically, rebuilding a vector index consumes memory equivalent to twice the size of the index. After enabling the memory-saving mode, the system releases memory by temporarily dropping the in-memory index of a single partition after that partition is built, effectively reducing the total memory required for the rebuild operation. For syntax and examples, see vector_index_memory_saving_mode.
Persist and merge control for incremental segments of HNSW series indexes
Vector indexes are organized by segment within a partition and can be classified as follows:
- Baseline segment: A read-only segment. Each partition typically has only one.
- Incremental segment: Generated by DML writes. Types include active incremental segment, frozen incremental segment, and persistence incremental segment.
For a single partition, you can use the following parameters to control the timing of freezing and persisting active incremental segments, and the merging of incremental segments with the baseline segment:
Persistence
ob_vector_index_active_segment_max_size controls the maximum memory usage of an active incremental segment within a single partition of a HNSW series index. When the memory of an active incremental segment exceeds this threshold, the system triggers a freeze. After the freeze is complete, the segment becomes a frozen incremental segment. After a frozen incremental segment is persisted to disk, it becomes a persistence incremental segment.
Notice
After a frozen incremental segment is persisted to disk as a persistence incremental segment, the memory is not immediately released. The memory usage will decrease only after a background major compaction task merges it into the baseline segment.
For syntax and examples, see ob_vector_index_active_segment_max_size.
Major compaction
ob_vector_index_merge_trigger_percentage controls the proportion of memory occupied by persistent incremental segments to the total memory of the persistent partition index. When the proportion exceeds this value, the system automatically triggers a segment major compaction to merge the incremental segments with the baseline segments.
The difference between the two parameters:
Parameter |
Control object |
Trigger operation |
|---|---|---|
| ob_vector_index_active_segment_max_size | Memory usage of active incremental segments (absolute value) | Freezing and persistence, transforming the segment into a frozen incremental segment or a persistence incremental segment |
| ob_vector_index_merge_trigger_percentage | Ratio of memory occupied by persistent incremental segments to the total memory of the persistent partition index | Segment major compaction, merging with the baseline segment |
Note
The above configurations apply to the "incremental write and persistence" and "incremental segment-to-baseline segment major compaction" pathways, respectively. Together, they balance write performance, query performance, and memory usage.
For syntax and examples, see ob_vector_index_merge_trigger_percentage.
References
- Overview of vector indexes
- For information about viewing segment information, understanding automatic index partition reconstruction, and manually forcing major compactions, see Monitor and maintain indexes