pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: margaret-pan (@margaret-pan) <noreply+margaret-pan@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #820: JOIN with distance limit doesn't use index?
Date: Sat, 12 Apr 2025 15:22:55 +0000
Message-ID: <gh-pgvector-pgvector-820@github.com> (raw)

I have two tables, let's call them `big` and `small`, each of which has a name column `big_id`, `small_id` (string) and a `coord` column (vector). I've added a HNSW index on the `coord` column to `big`, and I'd like to find the elements of `big` whose `coord`s are less than an l2-distance `0.002` away from the `coord` of each element of `small`. I'm trying to do this with a JOIN:

`SELECT small_id, array_agg(big_id) AS array_agg FROM small JOIN big ON l2_distance(big.coord, small.coord) < 0.002 GROUP BY small_id;`

EXPLAIN ANALYZE suggests that this isn't using the index on `big`. Is there a workaround to make it use the index?

view thread (4+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-820@github.com>
Permalink:  ../gh-pgvector-pgvector-820@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox