REBUILD_INDEX
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 | The name of the index. | Yes |
| table_name | The name of the table. | Yes |
| idx_vector_col | The name of the vector column. | Yes |
| delta_rate_threshold | The proportion of incremental data. The default value is 0.2, and the value range is [0, 1]. | No |
| idx_organization | The type of the index. The default value is NULL, and custom parameters are not supported. | No |
| idx_distance_metrics | The distance type. The default value is NULL, and custom parameters are not supported. | No |
| idx_parameters | The index parameters. This parameter is the string of vector index parameters used when the table was created, such as distance=l2, type=hnsw, lib=vsag. | No |
| idx_parallel_creation | The parallelism for parallel index construction. | No |
Notes:
- When rebuilding an index, you must specify the table name, index name, and index column.
- If you do not specify
delta_rate_threshold, the index may not be rebuilt. To forcibly rebuild the index, you must specifydelta_rate_threshold=0. - You can set the parallelism to accelerate the index rebuild.
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.
-- Trigger a full update.
-- Set the parallelism to 8.
CALL DBMS_VECTOR.REBUILD_INDEX('idx1','vector_index_test','c2','','','','',8);
-- Do not set the parallelism.
CALL DBMS_VECTOR.REBUILD_INDEX('idx1','vector_index_test','c2');