Vector DBs & RAG (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
How do Vector Databases implement dynamic updates and deletions in HNSW graphs?
senior LevelMost AskedDatabases & SQLData Structures
In Simple Words: HNSW graphs are notoriously difficult to update dynamically because deleting a node leaves dangling edges and damages graph connectivity:
- Tombstoning (Soft Deletion): Nodes are marked deleted in a bitset; search algorithms skip tombstoned nodes during traversal.
- Edge Re-wiring: Background worker threads periodically repair connections by joining incoming neighbors with outgoing neighbors.
- Compaction / Segment Merge: Similar to Lucene, vector engines (Qdrant, Milvus) write immutable segment files. Once tombstones exceed a threshold (e.g. 20%), the engine rebuilds clean HNSW segments in the background.