pgvector.git / summary / log / commit / refs
commit f1983ce6722417e1f056f83ea2faf0d89cd6c71b
Author: Andrew Kane <andrew@ankane.org>
Date: Mon Mar 06 01:34:49 2023 +0000
Added section on querying - #64 [skip ci]
README.md | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/README.md b/README.md
index 71a71f7a..c8a3a1cd 100644
--- a/README.md
+++ b/README.md
@@ -145,6 +145,22 @@ To index many different values of `category_id`, consider [partitioning](https:/
CREATE TABLE items (embedding vector(3), category_id int) PARTITION BY LIST(category_id);
```
+## Querying
+
+Use a `SELECT` clause to get the distance
+
+```sql
+SELECT embedding <-> '[3,1,2]' AS distance FROM items;
+```
+
+Use a `WHERE` clause to get rows within a certain distance
+
+```sql
+SELECT * FROM items WHERE embedding <-> '[3,1,2]' < 100;
+```
+
+Note: Combine with `ORDER BY` and `LIMIT` to use an index
+
## Performance
To speed up queries without an index, increase `max_parallel_workers_per_gather`.
[parent: 0a3615b82f1d]