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.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
pgvector is the easiest path to production vector search if your team already runs Postgres. The interview's signal is whether the candidate knows the two index types, their history, and the 2026 default reach. Getting this wrong outs a candidate as having read a 2022 tutorial; getting it right shows they have tracked the extension's evolution.
Timeline and why ordering matters
pgvector was created by Andrew Kane and gained traction in 2022 when GPT-3-era RAG pipelines drove demand for vector search inside an existing Postgres. The 0.4.0 release (mid-2022) added the vector data type and IVFFlat as the first ANN index. IVFFlat shipped first because it's a static partitioning, which integrates cleanly with Postgres' access-method API.
HNSW arrived in 0.5.0 (mid-2023). Implementing it required reworking the access method to handle dynamic graph maintenance under MVCC, WAL replay, and concurrent inserts. Once it landed, it quickly displaced IVFFlat as the default because of its superior recall vs latency profile and graceful handling of inserts.
By 2024 onward, Supabase, Neon, RDS Postgres, and the major Postgres cloud vendors all defaulted their tutorials to HNSW. IVFFlat became a 'use this if you specifically need it' option.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
| 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.
- Supabase, Neon, and AWS RDS for Postgres all ship pgvector with HNSW support; their cookbook examples default to HNSW.
- pgvectorscale (Timescale) adds disk-based HNSW variants for billion-scale workloads on Postgres.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhat is the rule of thumb for `lists` in IVFFlat?
lists ~ sqrt(N) for N vectors. For 10M vectors, lists ~ 3162. Then probes is tuned at query time per the recall SLO.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases 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.
60 second bullets to scan on the way to the call.
HNSW landed in pgvector 0.5.0 (mid-2023) as the second index type
IVFFlat predates it because k-means + lists fits Postgres' access-method API naturally
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.