mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 08:36:54 +08:00
Improved performance section [skip ci]
This commit is contained in:
20
README.md
20
README.md
@@ -410,13 +410,29 @@ You can use [Reciprocal Rank Fusion](https://github.com/pgvector/pgvector-python
|
|||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
|
### Loading
|
||||||
|
|
||||||
|
Use `COPY` for bulk loading data ([example](https://github.com/pgvector/pgvector-python/blob/master/examples/bulk_loading.py)).
|
||||||
|
|
||||||
|
```sql
|
||||||
|
COPY items (embedding) FROM STDIN WITH (FORMAT BINARY);
|
||||||
|
```
|
||||||
|
|
||||||
|
Add any indexes *after* loading the data.
|
||||||
|
|
||||||
|
### Indexing
|
||||||
|
|
||||||
|
See index build time for [HNSW](#index-build-time) and [IVFFlat](#index-build-time-1).
|
||||||
|
|
||||||
|
### Querying
|
||||||
|
|
||||||
Use `EXPLAIN ANALYZE` to debug performance.
|
Use `EXPLAIN ANALYZE` to debug performance.
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
EXPLAIN ANALYZE SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;
|
EXPLAIN ANALYZE SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Exact Search
|
#### Exact Search
|
||||||
|
|
||||||
To speed up queries without an index, increase `max_parallel_workers_per_gather`.
|
To speed up queries without an index, increase `max_parallel_workers_per_gather`.
|
||||||
|
|
||||||
@@ -430,7 +446,7 @@ If vectors are normalized to length 1 (like [OpenAI embeddings](https://platform
|
|||||||
SELECT * FROM items ORDER BY embedding <#> '[3,1,2]' LIMIT 5;
|
SELECT * FROM items ORDER BY embedding <#> '[3,1,2]' LIMIT 5;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Approximate Search
|
#### Approximate Search
|
||||||
|
|
||||||
To speed up queries with an IVFFlat index, increase the number of inverted lists (at the expense of recall).
|
To speed up queries with an IVFFlat index, increase the number of inverted lists (at the expense of recall).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user