experimental_hnsw_index

The experimental_hnsw_index system variable controls whether the HNSW (Hierarchical Navigable Small World) vector index plugin is enabled. When set to 0 (default), CREATE INDEX ... USING hnsw statements are rejected. Set it to 1 before 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

bool

Scope

Both

Dynamic

Yes

Default Value

0

Optional Value

0, 1

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_index defaults to 0. Attempting CREATE INDEX ... USING hnsw while the variable is 0 causes 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, and max_index_capacity. These can be specified in the CREATE INDEX or ALTER TABLE ... ALTER REINDEX statement.

  • This is an experimental feature. Its behavior, performance characteristics, and API may change in future releases.