8000 Updated readme [skip ci] · postgrespro/pgvector@572a9ab · GitHub
[go: up one dir, main page]

Skip to content

Commit 572a9ab

Browse files
committed
Updated readme [skip ci]
1 parent 00492d7 commit 572a9ab

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,14 +485,16 @@ WITH relaxed_results AS MATERIALIZED (
485485
) SELECT * FROM relaxed_results ORDER BY distance;
486486
```
487487

488-
For queries that filter by distance, use a materialized CTE and place the 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)
488+
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)
489489

490490
```sql
491-
WITH filtered_results AS MATERIALIZED (
492-
SELECT id, embedding <-> '[1,2,3]' AS distance FROM items WHERE category_id = 123 ORDER BY distance LIMIT 5
493-
) SELECT * FROM filtered_results WHERE distance < 0.1 ORDER BY distance;
491+
WITH nearest_results AS MATERIALIZED (
492+
SELECT id, embedding <-> '[1,2,3]' AS distance FROM items ORDER BY distance LIMIT 5
493+
) SELECT * FROM nearest_results WHERE distance < 5 ORDER BY distance;
494494
```
495495

496+
Note: Place any other filters inside the CTE
497+
496498
### Iterative Scan Options
497499

498500
Since scanning a large portion of an approximate index is expensive, there are options to control when a scan ends

0 commit comments

Comments
 (0)
0