learning-it by example

Back to the video

pgvector Tuning: When Filtered Vector Search Returns Nothing

On a table built as a hard case, a filtered vector search returned no rows, no error, and the plan said the index was used.

Video #50 ยท RAG and vector search

Steps in the video

  1. 0:00 A filtered vector search that returned nothing
  2. 0:27 The idea
  3. 1:07 Setup
  4. 1:33 Start the database
  5. 2:02 A table with a trap
  6. 2:30 Tune it, step by step
  7. 3:41 What this does not show
  8. 4:15 Mistakes to avoid
  9. 4:45 My take and next steps
  10. 5:14 Recap

Files

  • common.py (44 lines)
  • compare.py (30 lines)
  • compose.yaml (12 lines)

Download the code (zip)

Tested with

Python 3.12.15 | psycopg[binary]==3.3.6, pgvector==0.5.1, numpy==2.5.4

What this does not show

One made-up table of 20,000 rows and one query built to be a hard case, run on one laptop; no timings were measured. The Docker image tag pg17 floats: I saw pgvector 0.8.7 on Postgres 17, and a later pull may differ.

Sources

Learning IT by Example.