Vector databases without metadata pre-filtering are useless for multi-tenant enterprise RAG
A classic production bug in multi-tenant RAG systems happens quietly:
You index 2 million document chunks across 500 enterprise customers into a single HNSW vector index, then query:
sqlSELECT content FROM docs WHERE tenant_id = 'acme_corp' ORDER BY embedding <=> $1 LIMIT 10;
If your database performs post-filtering (fetch top-40 nearest neighbors globally, then filter WHERE tenant_id = 'acme_corp'):
- Suppose
acme_corponly owns 0.2% of the total chunks. - All 40 global nearest neighbors might belong to larger tenants!
- After the
WHEREfilter runs, your RAG pipeline receives 0 results—even though Acme Corp has 4,000 relevant documents in the database.
The Fix: Iterative Index Scans & Payload-Aware HNSW
Never ship multi-tenant RAG with naive post-filtering:
- In PostgreSQL (
pgvector 0.8+): EnableSET LOCAL hnsw.iterative_scan = relaxed_order;so the HNSW graph keeps traversing until it collects 10 validtenant_idmatches. - In Qdrant / Milvus: Create explicit keyword payload indexes on
tenant_idso graph traversal evaluates filter bitmasks inside each HNSW hop.
Zero-result hallucinations in multi-tenant RAG are almost always a vector filtering bug, not an LLM bug.