From: gustavfridell (@gustavfridell) <noreply+gustavfridell@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #902: Optimizing distance + date queries
Date: Fri, 26 Sep 2025 08:22:23 +0000
Message-ID: <gh-pgvector-pgvector-902@github.com> (raw)
Hi,
I have a use case where I need to retrieve all results within a certain distance threshold **and** order them by the `published_at` column. The challenge is that this prevents ordering by distance, which means I can't leverage an index to optimize these queries.
One idea I had was to first filter by date (using an index) to reduce the number of rows from millions to a few thousand, and then let Postgres perform a regular scan to check which rows are within the distance threshold. In practice, though, this approach is too slow for real-world usage.
Are there any practical strategies to make this more efficient using pgvector?