From 7265927fd6412f21afb6e376817810323e838a5d Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 28 Sep 2024 12:07:09 -0700 Subject: [PATCH] Updated readme [skip ci] --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ccf31a9..6061068 100644 --- a/README.md +++ b/README.md @@ -492,7 +492,7 @@ Specify the max number of probes SET ivfflat.max_probes = 100; ``` -### Streaming Order +### Streaming Caveats With streaming queries, it’s possible for rows to be slightly out of order by distance. For strict ordering, use: @@ -502,6 +502,14 @@ WITH approx_order AS MATERIALIZED ( ) SELECT * FROM approx_order ORDER BY distance; ``` +Distance filters should be placed outside the CTE for best performance. + +```sql +WITH approx_order AS MATERIALIZED ( + SELECT *, embedding <-> '[1,2,3]' AS distance FROM items WHERE ... ORDER BY distance LIMIT 5 +) SELECT * FROM approx_order WHERE distance < 0.1 ORDER BY distance; +``` + ## Half-Precision Vectors *Added in 0.7.0*