Database / Qdrant Vector DB Interview questions
What is the HNSW algorithm?
HNSW (Hierarchical Navigable Small World) is a graph-based approximate nearest neighbor algorithm that Qdrant uses as its default vector index, organizing vectors into a multi-layer graph structure that lets a search converge on nearby vectors in roughly logarithmic time rather than scanning the entire dataset.
The graph is built in layers: the top layer has very few nodes with long-range connections, acting as a coarse "highway" across the vector space, while lower layers have progressively more nodes and shorter, denser connections, down to the bottom layer that includes every vector.
A search starts at an entry point in the top layer, greedily moves to whichever connected neighbor is closest to the query at each step, and descends layer by layer, narrowing in on the query's actual neighborhood by the time it reaches the bottom layer — a process that visits a small fraction of the total vectors, which is what makes HNSW searches sub-linear in dataset size rather than scanning everything.
More Related questions...