HNSW Index Architecture: Transaction Support and Persistence

Hierarchical Navigable Small World (HNSW) indexes are specialized, memory-only structures designed for efficient vector search. Once an HNSW index is created, any subsequent inserts, updates, or deletes (DML operations) performed on the base table will not be reflected in the index.

To maintain accuracy, performance, and consistency with transactional data operations, Oracle employs several supporting data structures. This page outlines the key internal components used in maintaining transactional vector search and persistence for HNSW indexes.

Transaction Support Structures:

Graph Refresh and Persistence Structures:

Queries that come after an index is created would need to lookup the index as well as the DMLs that occurred after it to get the top-K result. With accumulating DMLs, queries become slower as the exact search on the shared journal vectors becomes more expensive than the approximate search on the currently indexed HNSW graph. To maintain performance and accuracy, Oracle provides automated graph refresh and persistence mechanisms.

Explicitly Specifying a Graph Refresh:

You can use the idx_rebuild_mode parameter of the DBMS_VECTOR.REBUILD_INDEX procedure to specify how the HNSW graph should be refreshed. This parameter accepts values : FULL or INCREMENTAL. This enables a full graph rebuild. By default, idx_rebuild_mode is set to NULL. In this case, the system follows the existing behavior: drop and recreates the index. The idx_rebuild_mode allows for a fine-grained control when managing index refresh operations.

An example which triggers a full repopulation:

execute dbms_vector.rebuild_index('galaxies_hnsw_idx',
            'galaxies',
            'embedding',
            NULL,
            NULL,
            'INMEMORY NEIGHBOR GRAPH',
            'EUCLIDEAN',
            95,
            FULL,
            '{"type" : "HNSW", "neighbors" : 3, "efConstruction" : 4 }') ;

Note: This code assumes that the index galaxies_hnsw_idx is already created on the galaxies table. See the Oracle documentation on Hierarchical Navigable Small World (HNSW) index syntax and parameters for guidance on creating an HNSW index.

HNSW indexes rely on these structures to balance performance and accuracy while retrieving transactionally consistent top-K results. Together, they ensure scalable, low-latency vector search even as tables evolve through frequent updates and deletes.