Click any words you think contain an error. Click again to unmark.
PQ is a compression scheme, not an index. Without IVF or HNSW on top, you still scan all N vectors per query (just with cheap distances). The correct framing is IVF-PQ vs HNSW, not PQ vs HNSW.
Saying 'we use PQ instead of HNSW' is like saying 'we use lightweight backpacks instead of a map and trail signs to find our way through the forest faster'. The backpack (PQ) makes each step lighter; the map and trail signs (HNSW or IVF) tell you which way to walk. You need both. **PQ is a compression scheme** that makes every comparison cheap; **HNSW is an index** that tells you which comparisons to even try. Mixing the two categories shows the speaker has not yet separated them in their head.
Detailed answer & concept explanation~2 min readEverything 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. 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.
3 min: spot the category error + name the two orthogonal axes (index vs encoding) + present the IVF-PQ / HNSW-PQ production patterns + offer the corrected sentence.
| Configuration | Index layer | Encoding layer | Billion-scale viable? |
|---|---|---|---|
| Pure float32 brute force | None (O(N) scan) | float32 | No (seconds per query) |
| Pure PQ scan | None (O(N) scan) | PQ | No (still O(N), even if each comparison is cheap) |
| Pure float32 HNSW | HNSW | float32 | Borderline (RAM is the bottleneck) |
| IVF-PQ | IVF | PQ | Yes (the canonical pattern) |
| HNSW-PQ | HNSW | PQ | Yes (higher recall, more memory than IVF-PQ) |
Real products, models, and research that use this idea.
- Faiss exposes IndexIVFPQ as the canonical billion-scale CPU index; pure IndexPQ exists but is a baseline, not a production target.
- Milvus offers both IVF_PQ and HNSW with PQ quantization; pure PQ scan is not a deployment target.
- Qdrant defaults to HNSW and offers PQ as an opt-in compression layer for vectors inside the HNSW graph.
- Weaviate's product quantization documentation explicitly notes that PQ is a compression scheme applied on top of HNSW, not a replacement for HNSW.
- Google's ScaNN combines IVF-style partitioning with PQ and learned codebooks (anisotropic loss); the index and encoding layers are still separate.
What an interviewer would ask next. Try answering before peeking at the approach.
QCould you imagine a case where pure-PQ scan beats HNSW-PQ?
QWhy is IVF-PQ generally chosen over HNSW-PQ at the very largest scales?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating PQ and HNSW (or IVF) as alternatives. They are orthogonal: compression vs index structure. Production systems combine them as HNSW-PQ or IVF-PQ.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.