experimental_hnsw_index¶
The
experimental_hnsw_indexsystem variable controls whether the HNSW (Hierarchical Navigable Small World) vector index plugin is enabled. When set to0(default),CREATE INDEX ... USING hnswstatements are rejected. Set it to1before creating or rebuilding an HNSW index to perform approximate nearest neighbor (ANN) search on vector columns. This is an experimental feature gated by a session-level flag.
The experimental_hnsw_index system variable gates access to the HNSW vector index algorithm
in MatrixOne. HNSW is a graph-based algorithm that provides high-performance approximate nearest
neighbor search for vector data. Because this is an experimental feature, the variable defaults
to 0 and must be explicitly enabled before it can be used.
Syntax¶
SET GLOBAL experimental_hnsw_index = 0; SET SESSION experimental_hnsw_index = 1;
Query the current value:
SHOW VARIABLES LIKE ‘experimental_hnsw_index’; SELECT @@experimental_hnsw_index;
Arguments¶
Property |
Value |
|---|---|
Variable Type |
|
Scope |
|
Dynamic |
|
Default Value |
|
Optional Value |
|
Examples¶
DROP DATABASE IF EXISTS hnsw_demo;
CREATE DATABASE hnsw_demo;
USE hnsw_demo;
SET experimental_hnsw_index = 1;
CREATE TABLE h(a BIGINT PRIMARY KEY, v VECF32(3));
INSERT INTO h VALUES (1, '[1,1,1]'), (2, '[2,2,2]'), (3, '[3,3,3]'), (4, '[8,8,8]');
CREATE INDEX ix USING hnsw ON h(v) OP_TYPE "vector_l2_ops" MAX_INDEX_CAPACITY 1000000;
SELECT a FROM h ORDER BY L2_DISTANCE(v, '[1,1,1]') ASC LIMIT 2;
SET experimental_hnsw_index = 0;
DROP TABLE h;
DROP DATABASE hnsw_demo;
Constraints¶
experimental_hnsw_indexdefaults to0. AttemptingCREATE INDEX ... USING hnswwhile the variable is0causes the operation to fail.HNSW is a CPU-only algorithm. It does not require GPU hardware.
The HNSW index supports the following build-option parameters:
m,ef_construction,ef_search, andmax_index_capacity. These can be specified in theCREATE INDEXorALTER TABLE ... ALTER REINDEXstatement.This is an experimental feature. Its behavior, performance characteristics, and API may change in future releases.