REBUILD_INDEX
Use the DBMS_VECTOR.REBUILD_INDEX procedure to rebuild a
vector index.
Purpose
To rebuild a vector index such as Hierarchical Navigable Small World (HNSW) vector
index or Inverted File Flat (IVF) vector index. If idx_rebuild_mode
is passed as non-NULL, the index is rebuilt using HNSW refresh
support. If it is passed as NULL, the index is dropped and then
recreated using the new index parameters.
Syntax
DBMS_VECTOR.REBUILD_INDEX (
idx_name IN VARCHAR2,
table_name IN VARCHAR2 DEFAULT NULL,
idx_vector_col IN VARCHAR2 DEFAULT NULL,
idx_include_cols IN VARCHAR2 DEFAULT NULL,
idx_partitioning_scheme IN VARCHAR2 DEFAULT NULL,
idx_organization IN VARCHAR2 DEFAULT NULL,
idx_distance_metric IN VARCHAR2 DEFAULT NULL,
idx_accuracy IN NUMBER DEFAULT NULL,
idx_parameters IN CLOB DEFAULT NULL,
idx_parallel_creation IN NUMBER DEFAULT NULL,
idx_rebuild_mode IN VARCHAR2 DEFAULT NULL,
idx_quantization_type IN VARCHAR2 DEFAULT NULL,
idx_compression_ratio IN NUMBER DEFAULT NULL,
idx_distribute_parameters IN CLOB DEFAULT NULL,
idx_duplicate_parameters IN CLOB DEFAULT NULL,
idx_online_build IN BOOLEAN DEFAULT NULL,
idx_owner IN VARCHAR2 DEFAULT NULL
);Parameters
| Parameter | Description |
|---|---|
|
|
Name of the index to rebuild. |
|
|
Table on which to create the index. |
|
|
Vector column on which to create the index. |
idx_include_cols |
A comma-separated list of column names to be covered by the index. |
|
|
Partitioning scheme for IVF indexes:
IVF indexes support both global and local indexes on partitioned tables. By default, these indexes are globally partitioned by centroid. You can choose to create a local IVF index, which provides a one-to-one relationship between the base table partitions or subpartitions and the index partitions. For detailed information on these partitioning schemes, see Inverted File Flat Vector Indexes Partitioning Schemes. |
|
|
Index organization:
For detailed information on these organization types, see Manage the Different Categories of Vector Indexes. |
|
|
Distance metric or mathematical function used to compute the distance between vectors:
For detailed information on each of these metrics, see Vector Distance Functions and Operators. |
|
|
Target accuracy at which the approximate search should be performed when running an approximate search query. As explained in Understand Approximate Similarity Search Using Vector Indexes, you can specify non-default target accuracy values either by specifying a percentage value or by specifying internal parameters values, depending on the index type you are using.
|
|
|
Type of vector index and associated parameters. Specify the indexing parameters in JSON format:
|
|
|
Number of parallel threads used for index construction. |
|
|
Supported values:
By default, this parameter is set to This parameter is only supported for HNSW vector indexes. |
|
|
Optional replacement quantization type to apply to the rebuilt index. The supported values are |
|
|
Optional replacement compression ratio for a quantized vector index. This is provided either as a numeric value or
|
|
|
Optional replacement distribution settings for a distributed HNSW vector index. The value is provided as
This parameter is only supported for HNSW indexes and
can only be used if |
|
|
Optional replacement duplication settings for a distributed HNSW vector index. The value is expected to be either
This parameter is only supported for HNSW indexes and
can only be used if |
|
|
Optional replacement online build setting to use when recreating the vector index. The values accepted are |
|
|
Specify the owning schema of the index to be rebuilt.
The index will be rebuilt in the same schema. Use the default
value, |
Usage Notes
For all parameters besides idx_name, if the value is passed as
NULL (the default), the procedure uses the same value that was
used by the index before the rebuild.
Examples
-
Specify neighbors and efConstruction for HNSW indexes:
BEGIN DBMS_VECTOR.REBUILD_INDEX( idx_name => 'v_hnsw_01', table_name => 'vpt01', idx_vector_col => 'EMBEDDING', idx_include_cols => NULL, idx_partitioning_scheme => NULL, idx_organization => 'INMEMORY NEIGHBOR GRAPH', idx_distance_metric => 'EUCLIDEAN', idx_accuracy => 95, idx_parameters => '{ "type" : "HNSW", "neighbors" : 3, "efConstruction" : 4 }' ); END; / -
Specify the number of partitions for IVF indexes:
BEGIN DBMS_VECTOR.REBUILD_INDEX( idx_name => 'V_IVF_01', table_name => 'vpt01', idx_vector_col => 'EMBEDDING', idx_include_cols => NULL, idx_partitioning_scheme => NULL, idx_organization => 'NEIGHBOR PARTITIONS', idx_distance_metric => 'EUCLIDEAN', idx_accuracy => 95, idx_parameters => '{ "type" : "IVF", "partitions" : 5 }' ); END; / -
To enable a full graph rebuild:
BEGIN DBMS_VECTOR.REBUILD_INDEX( idx_name => 'v_hnsw_01', table_name => 'vpt01', idx_vector_col => 'EMBEDDING', idx_include_cols => NULL, idx_partitioning_scheme => NULL, idx_organization => 'INMEMORY NEIGHBOR GRAPH', idx_distance_metric => 'EUCLIDEAN', idx_accuracy => 95, idx_parameters => '{ "type" : "HNSW", "neighbors" : 3, "efConstruction" : 4 }', idx_rebuild_mode => 'FULL' ); END; / -
Specify a scalar quantized HNSW index rebuild:
BEGIN DBMS_VECTOR.REBUILD_INDEX( idx_name => 'V_HNSW_01', idx_vector_col => 'EMBEDDING', idx_quantization_type => 'SCALAR', idx_compression_ratio => 4, idx_parameters => '{ "type" : "HNSW", "neighbors" : 32, "efConstruction" : 200, "rescore factor" : 2, "algorithm" : "uniform_quantization" }' ); END; /
Parent topic: DBMS_VECTOR