pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: ankane (@ankane) <noreply+ankane@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #862: Inconsistent behavior with relaxed_order: planner assumes strict ordering from HNSW index
Date: Tue, 01 Jul 2025 17:01:45 +0000
Message-ID: <gh-pgvector-pgvector-862-c3024850415@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-862@github.com>
References: <gh-pgvector-pgvector-862@github.com>

Thanks @redphosphorus7562.

The out-of-order results are due to the normalization with cosine distance, which can cause the index ordering to be slightly different than the heap (since floating point has limited precision). This can likely be addressed by storing the original vectors and L2 norm separately in the index (rather than storing normalized vectors).

For the materialized CTE, it looks like Postgres no longer adds a sort node with 17+, so users will need to do `ORDER BY distance + 0`. Will update the docs to reflect this.

view thread (8+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-862-c3024850415@github.com>
Permalink:  ../gh-pgvector-pgvector-862-c3024850415@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