Local Hierarchical Navigable Small World Indexes

A local HNSW index is an index created for each partition or sub partition of a partitioned table. Instead of building a single, global HNSW (Hierarchical Navigable Small World) graph across all vectors in a large, partitioned table, Oracle enables the creation of individual HNSW graphs for each (sub)partition. This local partitioned indexing approach improves scalability, performance, and manageability essential for enterprise workloads involving high-dimensional similarity search applications, such as semantic search, recommendation systems, and AI-driven analytics.

In addition, partition pruning and parallel execution further optimize query efficiency.

When using partition pruning, Oracle AI Database restricts query processing to only those partitions that satisfy the query’s filtering predicates. The optimizer analyzes FROM and WHERE clauses in SQL statements to eliminate unneeded partitions thereby minimizing unnecessary data access and computation. When using local HNSW vector indexes, you may see different optimizer plans for similarity searches. For more information about optimizer plans, see Optimizer Plans for Local HNSW Vector Indexes.

For example, if a houses table is partitioned by state column using list or hash partitioning, and a query specifies WHERE state = 'CA', then the database performs partition pruning. It searches only the CA partition and its local HNSW index to process the query:

SELECT id
FROM houses
WHERE state = 'CA'
ORDER BY vector_distance(data_vector, :query_vector)
FETCH FIRST 10 ROWS ONLY;

--With a local HNSW index, only the CA partition and its local HNSW graphs are searched.

For more information on partition pruning, see Partition Pruning.

Parallel execution further amplifies efficiency by allowing multiple partitions and their corresponding local HNSW indexes to be searched simultaneously across multiple CPU threads.

Usage Notes

Syntax

CREATE VECTOR INDEX VIDX_HNSW ON HOUSES(VEC) ORGANIZATION INMEMORY NEIGHBOR GRAPH [WITH TARGET ACCURACY 95] [DISTANCE EUCLIDEAN] [PARAMETERS (type HNSW, neighbors 32, efConstruction 500)] LOCAL;

Example

CREATE VECTOR INDEX VIDX_HNSW ON HOUSES(VEC)
  ORGANIZATION INMEMORY NEIGHBOR GRAPH
  [WITH TARGET ACCURACY 95]
  [DISTANCE EUCLIDEAN]
  [PARAMETERS (type HNSW, neighbors 32, efConstruction 500)]
  LOCAL
  PARALLEL 4;

See Also: Hierarchical Navigable Small World Index Syntax and Parameters