pgvector.git / summary / log / commit / refs
commit ae9ee81e4de7e41569395a3d3dfc86253dadcd02
Author: Andrew Kane <andrew@ankane.org>
Date: Tue Jul 01 17:11:50 2025 +0000
Fixed relaxed results example for Postgres 17 - #862 [skip ci]
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d4d2f49f..ab8a06dd 100644
--- a/README.md
+++ b/README.md
@@ -492,7 +492,7 @@ With relaxed ordering, you can use a [materialized CTE](https://www.postgresql.o
```sql
WITH relaxed_results AS MATERIALIZED (
SELECT id, embedding <-> '[1,2,3]' AS distance FROM items WHERE category_id = 123 ORDER BY distance LIMIT 5
-) SELECT * FROM relaxed_results ORDER BY distance;
+) SELECT * FROM relaxed_results ORDER BY distance + 0;
```
For queries that filter by distance, use a materialized CTE and place the distance filter outside of it for best performance (due to the [current behavior](https://www.postgresql.org/message-id/flat/CAOdR5yGUoMQ6j7M5hNUXrySzaqZVGf_Ne%2B8fwZMRKTFxU1nbJg%40mail.gmail.com) of the Postgres executor)
[parent: fa1dee4e3b29]