Zenaique

pgvector ships two index types. Which should be your default reach in 2026, and why was it added later than the other?

Flashcard·Easy·4.0 · 0·~30s·Asked atHebbiaJpmorganMercor·Relevant atMicrosoft
Attempt it
TL;DR

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.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

Key concepts

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.

Why HNSW is harder to ship inside Postgres
When to still reach for IVFFlat
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
PropertyIVFFlatHNSW
pgvector version0.4.0 (2022)0.5.0 (mid-2023)
Algorithm familyPartition (k-means)Graph (small-world)
Training requiredYes (representative sample)No
Inserts degrade recallYes (drift over time)No
Memory footprintSmallerLarger (graph + vectors)
Recall ceilingLower at same latencyHigher at same latency
Default reach in 2026Memory-constrained onlyYes

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.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhat is the rule of thumb for `lists` in IVFFlat?
A

lists ~ sqrt(N) for N vectors. For 10M vectors, lists ~ 3162. Then probes is tuned at query time per the recall SLO.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Defaulting to IVFFlat because it appears first in older pgvector tutorials, and then puzzling at why recall degrades after a few weeks of inserts.

Sign in to see all red flags and common mistakes.

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

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
HNSW vs IVF, when…
Flashcard·Medium