pgvector.git / summary / log / commit / refs
commit 5d0f88529e73dbabe27e627c42d104ac9cfd2fe8
Author: Andrew Kane <andrew@ankane.org>
Date: Fri Mar 31 23:28:27 2023 +0000
Updated readme [skip ci]
README.md | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index c5185da6..e1c7eeee 100644
--- a/README.md
+++ b/README.md
@@ -173,22 +173,32 @@ CREATE TABLE items (embedding vector(3), category_id int) PARTITION BY LIST(cate
## Performance
+Use `EXPLAIN ANALYZE` to debug performance.
+
+```sql
+EXPLAIN ANALYZE SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 1;
+```
+
+### Exact Search
+
To speed up queries without an index, increase `max_parallel_workers_per_gather`.
```sql
SET max_parallel_workers_per_gather = 4;
```
-To speed up queries with an index, increase the number of inverted lists (at the expense of recall).
+If vectors are normalized to length 1 (like those from [OpenAI](https://platform.openai.com/docs/guides/embeddings/limitations-risks)), use inner product instead of cosine distance for best performance.
```sql
-CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 1000);
+SELECT * FROM items ORDER BY embedding <#> '[3,1,2]' LIMIT 1;
```
-Use `EXPLAIN ANALYZE` to debug performance.
+### Approximate Search
+
+To speed up queries with an index, increase the number of inverted lists (at the expense of recall).
```sql
-EXPLAIN ANALYZE SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 1;
+CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 1000);
```
## Languages
[parent: 1d020abdd138]