pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] issue #858: Inconsistent result count when ordering by pgvector distance ASC vs DESC
3+ messages / 2 participants
[nested] [flat]
* [pgvector/pgvector] issue #858: Inconsistent result count when ordering by pgvector distance ASC vs DESC
@ 2025-06-12 06:47 "itsitsiridakis (@itsitsiridakis)" <noreply+itsitsiridakis@github.com>
0 siblings, 0 replies; 3+ messages in thread
From: itsitsiridakis (@itsitsiridakis) @ 2025-06-12 06:47 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
When running a query with <-> distance ordering on a vector column, I get significantly fewer results with order by asc than with order by desc.
Running this query with order by asc
`SELECT u0."user_id",
u0."embedding" <-> (SELECT embedding FROM users_embedding WHERE user_id = '306753')
FROM "users_embedding" u0
WHERE u0."user_id" != '306753'
ORDER BY 2 ASC
LIMIT 500;`
i get only 41 results, notice that i have 13k entries in the `users_embedding` table
<img width="411" alt="Image" src="https://github.com/user-attachments/assets/a809f14d-ceb9-4d92-accf-c3c8dd93d6d7"; />
Now if i run the same query order by desc
`SELECT u0."user_id",
u0."embedding" <-> (SELECT embedding FROM users_embedding WHERE user_id = '306753')
FROM "users_embedding" u0
ORDER BY 2 DESC
LIMIT 500;`
i get 500 results
<img width="318" alt="Image" src="https://github.com/user-attachments/assets/901cac52-decd-4409-8006-bca739702acc"; />
Table definition and indexes are below
<img width="793" alt="Image" src="https://github.com/user-attachments/assets/fe6624c4-fe3d-4ff9-b373-b8ac651d9e21"; />
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #858: Inconsistent result count when ordering by pgvector distance ASC vs DESC
@ 2025-06-12 11:26 "ankane (@ankane)" <noreply+ankane@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: ankane (@ankane) @ 2025-06-12 11:26 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Hi @iosif-t, check out the [troubleshooting docs](https://github.com/pgvector/pgvector?tab=readme-ov-file#why-are-there-less-results-for-a-query-after...).
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #858: Inconsistent result count when ordering by pgvector distance ASC vs DESC
@ 2025-06-12 11:26 "ankane (@ankane)" <noreply+ankane@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: ankane (@ankane) @ 2025-06-12 11:26 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2025-06-12 11:26 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-06-12 06:47 [pgvector/pgvector] issue #858: Inconsistent result count when ordering by pgvector distance ASC vs DESC "itsitsiridakis (@itsitsiridakis)" <noreply+itsitsiridakis@github.com>
2025-06-12 11:26 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-06-12 11:26 ` "ankane (@ankane)" <noreply+ankane@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