Skip to main content
MEM0 CONTEXTGRAPH LAB // VECTOR GRAPH RAM & PROMPT-TOKEN TCO STUDIO QDRANT INT8 + PGVECTOR HNSW | VULTR HIGH FREQUENCY | XIAOMI MIMO EXTRACTOR | 2026-10-19
Mem0VectorTCO
Mem0VectorTCO Affiliate Notice: Outbound /go/ links marked rel="sponsored" may earn a partner commission at zero added cost (Affiliate Policy).
HNSW & Token Tuning

pgvector IVFFlat vs HNSW: Build Time, Recall & RSS Memory

Understand why pgvector HNSW outperforms IVFFlat on streaming agent writes and how to cap maintenance_work_mem build spikes.

HNSW: 1.35x Build RSS · Streaming Safe · No Re-Clustering

pgvector IVFFlat vs HNSW: Build Time, Recall & RSS Memory
Memory benchmark baseline verified 2026-10-19 by ContextGraph Lab.

Why IVFFlat Fails Dynamic Agent Memory

IVFFlat partitions space around initial k-means centroids. Because agent memory grows continuously as users converse, early centroids go stale and recall drops silently unless you rebuild indexes offline.

Preventing maintenance_work_mem Spill

If maintenance_work_mem is too small when creating an HNSW index, PostgreSQL falls back to disk-backed graph construction that runs 10x slower. Size maintenance_work_mem to at least 1-2 GB on 8-16 GB nodes.

Measured Thresholds & Vector Stack Parameters

pgvector Index TypeStreaming InsertsBuild RAM & Recall Profile
IVFFlat (lists=1000)Degrades as data shiftsLow build RAM, requires periodic REINDEX
HNSW (m=16, ef=64)Handles continuous add()Needs 1.35x index size in maintenance_work_mem
HNSW halfvec(1536)Handles continuous add()50% smaller index & build RSS than fp32
HNSW: 1.35x Build RSS · Streaming Safe · No Re-Clustering Deploy Vultr HF NVMeXiaomi MiMo API