S
Supabase•4w ago
os

Supabase/Pgvector -> Very Slow

Hi Supabase team 👋 I'm using Supabase with pgvector for a vector search use case and I'm experiencing increasing latency when fetching chunks as my dataset grows. I'm querying the document_embeddings table (with ~30k rows currently) using: ```sql SELECT 1 - (embedding <#> $1) AS similarity, content FROM document_embeddings ORDER BY embedding <#> $1 LIMIT 15; I also created an HNSW index: CREATE INDEX ON document_embeddings USING hnsw (embedding vector_l2_ops); Even with this index, fetching just 15 results takes ~8 seconds, and it's getting slower as I add more data. I expected sub-200ms latency for this scale. I'm using supabase free account now. Do you think if I switch to Supabase pro i'll have 300ms for chunks fetching? Also, my total chunks will be 800k (so far i'm just testing with 30k and i can see already very slow comparing to 5k of chunks) Thank you
2 Replies
garyaustin
garyaustin•4w ago
There are a few pgvector users here. You might also look at the repository https://github.com/pgvector/pgvector to see if there are suggestions. There should not be anything Supabase specific about this as it is a Postgres extension. Pro doubles your memory from 512MB which is tight with all the things running just in the base db.
vick
vick•3w ago
what is the data type of your document_embeddings column precisely? I recall reading at one point that if you don't specify the length of the vector that the index doesn't necessarily work. it may be helpful to see if your index is actually being used by utilizing the EXPLAIN sql function on your query.

Did you find this page helpful?