Crunchy Data
Read post

Hybrid Search Patterns with Postgres and pgvector

Filtered vector search in Postgres creates a fundamental tension between recall and performance because ANN indexes (HNSW, IVFFlat) and WHERE clauses cannot be intersected like B-trees. The post explains why this happens and covers four practical patterns: pgvector iterative index scans (with tuning for max_scan_tuples, ef_search, and strict vs relaxed ordering), partial HNSW indexes for stable low-cardinality filters, oversampling with a pool_size formula derived from pg_stats selectivity estimates, and caching hybrid query results in a Postgres lookup table. A decision guide maps each pattern to the right use case, and EXPLAIN output examples help diagnose which plan the planner actually chose.

    #postgresql#rag#vector-search#pgvector
Jul 30•15m read time•From crunchydata.com
Post cover image
Table of contents
When nearest neighbor meets a WHERE clausepgvector iterative index scansWorkarounds and TricksDiagnosing plan choice with EXPLAINChoosing a workaround
638 Impressions
Crunchy Data's image
Crunchy Data

CrunchyData's platform is a central hub for PostgreSQL professionals and database administrators, of...

107 Followers

•

900 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard