pgvector ships two index types. Which should be your default reach in 2026, and why was it added later than the other?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
HNSW is the 2026 default in pgvector. IVFFlat predates it because it was easier to bolt onto Postgres' access-method API; HNSW landed in pgvector 0.5.0 (mid-2023) and now dominates.
pgvector is like a Postgres extension that adds two filing systems for vectors. The **older one (IVFFlat)** sorts your vectors into a few hundred labeled bins, but the labels are decided when you first build the index. If you keep adding new vectors, the bins drift and your search quality slowly degrades until you rebuild. The **newer one (HNSW)** builds a graph of connections that you can keep extending as new vectors arrive, without rebuilding. Everyone reaches for HNSW first unless they specifically need the smaller memory footprint of IVFFlat.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
2 min: name HNSW as the 2026 default + cite pgvector 0.5.0 timing + IVFFlat training/drift weakness + Postgres MVCC reason HNSW took longer.
| Property | IVFFlat | HNSW |
|---|---|---|
| pgvector version | 0.4.0 (2022) | 0.5.0 (mid-2023) |
| Algorithm family | Partition (k-means) | Graph (small-world) |
| Training required | Yes (representative sample) | No |
| Inserts degrade recall | Yes (drift over time) | No |
| Memory footprint | Smaller | Larger (graph + vectors) |
| Recall ceiling | Lower at same latency | Higher at same latency |
| Default reach in 2026 | Memory-constrained only | Yes |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Defaulting to IVFFlat because it appears first in older pgvector tutorials, and then puzzling at why recall degrades after a few weeks of inserts.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.