A user encountered significant issues with pgvector's HNSW index when implementing a retrieval-augmented generation (RAG) system for a multi-tenant documentation assistant. The core problem was that PostgreSQL's filtering, specifically a `WHERE tenant_id = $1` clause, was applied *after* the HNSW index selected candidate vectors. This resulted in many queries returning fewer than the requested 10 results, and in some cases, zero results, leading to the AI model incorrectly stating information was not in the documentation. Adjusting `hnsw.ef_search` and utilizing `hnsw.iterative_scan = relaxed_order` in pgvector 0.8 significantly improved retrieval counts, while for very small tenants, a direct exact scan proved more efficient than using the vector index. AI
IMPACT Highlights potential pitfalls in RAG system implementation, emphasizing the need for careful index configuration and retrieval validation.
RANK_REASON The item details a specific technical issue and its resolution within a database extension used for AI applications.
AI-generated summary · Google Gemini · from 1 sources. How we write summaries →