pgvector HNSW Index Silently Returns Fewer Results for Restricted Users in AI Search

AI search systems built on PostgreSQL with pgvector can quietly return far fewer results to users with limited document permissions when an HNSW vector index is enabled. The index scans a fixed candidate list — 40 rows by default — and applies permission filters afterward, meaning users who can read only 10% of documents may receive as few as 1 result instead of the expected 20. Because no error is thrown and no data leaks, the issue goes undetected, especially since developers typically test with broad-access accounts that always return full results. This can cause AI assistants to give incomplete or misleading answers to restricted users, such as incorrectly stating a policy does not exist. pgvector 0.8.0 introduced iterative index scans, which resolved the recall gap in testing but increased median query time from 1.7 ms to roughly 18–28 ms depending on the mode used.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in