The REBUILD_INDEX procedure is used to fully refresh (i.e., rebuild) a vector index.
Syntax
PROCEDURE REBUILD_INDEX(
IN IDX_NAME VARCHAR(65535),
IN TABLE_NAME VARCHAR(65535),
IN IDX_VECTOR_COL VARCHAR(65535) DEFAULT NULL,
IN DELTA_RATE_THRESHOLD FLOAT DEFAULT 0.2,
IN IDX_ORGANIZATION VARCHAR(65535) DEFAULT NULL,
IN IDX_DISTANCE_METRICS VARCHAR(65535) DEFAULT 'EUCLIDEAN',
IN IDX_PARAMETERS LONGTEXT DEFAULT NULL,
IN IDX_PARALLEL_CREATION INT DEFAULT 1);
Parameters
Parameter |
Description |
Required |
|---|---|---|
| idx_name | Index name. | Required |
| table_name | Table name. | Required |
| idx_vector_col | Vector column name. | Required |
| delta_rate_threshold | The proportion of incremental data. Default value: 0.2, with a value range of [0, 1]. |
Optional |
| idx_organization | Index type. Default: NULL, which does not support custom parameters. |
Optional |
| idx_distance_metrics | Distance type. Default: NULL, custom parameters are not supported. |
Optional |
| idx_parameters | Index parameters. The vector index parameter string used during table creation, for example, distance=l2, type=hnsw, lib=vsag For more parameters, see Monitor and maintain indexes. |
Optional |
| idx_parallel_creation | The degree of parallelism for building indexes in parallel. | Optional |
Consider the following:
- You must specify the table name, index name, and index column when rebuilding an index.
- If
delta_rate_thresholdis not specified, index rebuilding may not be triggered. To force a rebuild, setdelta_rate_threshold=0. - You can set the degree of parallelism to accelerate index rebuilding.
Examples
Create a test table.
CREATE TABLE vector_index_test(c1 INT, c2 VECTOR(3), PRIMARY KEY(c1), VECTOR INDEX idx1(c2) WITH (distance=l2, type=hnsw, lib=vsag));
Write test data.
INSERT INTO vector_index_test VALUES(1, '[0.203846,0.205289,0.880265]');
INSERT INTO vector_index_test VALUES(2, '[0.484526,0.669954,0.986755]');
INSERT INTO vector_index_test VALUES(3, '[0.327936,0.048756,0.084670]');
INSERT INTO vector_index_test VALUES(4, '[0.148869,0.878546,0.028024]');
INSERT INTO vector_index_test VALUES(5, '[0.334970,0.857377,0.886132]');
INSERT INTO vector_index_test VALUES(6, '[0.117582,0.302352,0.471198]');
INSERT INTO vector_index_test VALUES(7, '[0.551185,0.231134,0.075354]');
INSERT INTO vector_index_test VALUES(8, '[0.185221,0.315131,0.558301]');
INSERT INTO vector_index_test VALUES(9, '[0.928764,0.254038,0.272721]');
Trigger an update.
-- Triggers a full update.
-- Set the degree of parallelism to 8.
CALL DBMS_VECTOR.REBUILD_INDEX('idx1','vector_index_test','c2','','','','',8);
-- The degree of parallelism is not set.
CALL DBMS_VECTOR.REBUILD_INDEX('idx1','vector_index_test','c2');