You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -485,14 +485,16 @@ WITH relaxed_results AS MATERIALIZED (
485
485
)SELECT*FROM relaxed_resultsORDER BY distance;
486
486
```
487
487
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 thedistancefilter 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)
489
489
490
490
```sql
491
-
WITHfiltered_resultsAS MATERIALIZED (
492
-
SELECT id, embedding<->'[1,2,3]'AS distanceFROM itemsWHERE category_id=123ORDER BY distanceLIMIT5
493
-
)SELECT*FROMfiltered_resultsWHERE distance<0.1ORDER BY distance;
491
+
WITHnearest_resultsAS MATERIALIZED (
492
+
SELECT id, embedding<->'[1,2,3]'AS distanceFROM itemsORDER BY distanceLIMIT5
493
+
)SELECT*FROMnearest_resultsWHERE distance<5ORDER BY distance;
494
494
```
495
495
496
+
Note: Place any other filters inside the CTE
497
+
496
498
###Iterative Scan Options
497
499
498
500
Since scanning a large portion of an approximate index is expensive, there are options to control when a scan ends