pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: huaimin016 (@huaimin016) <noreply+huaimin016@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #666: search too slow when I clean the cache
Date: Sat, 07 Sep 2024 03:21:46 +0000
Message-ID: <gh-pgvector-pgvector-666-c2335020811@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-666@github.com>
References: <gh-pgvector-pgvector-666@github.com>

Hi!
For binary quantization, I used rerank for reordering, and the recall is still not high. When the limit is 500, the recall is about 40%, and when the limit is 100, it is only 10% or even lower, depending on the search content.

Also I found that I can use`SELECT pg_prewarm('test_pg_hnsw_half_index_vector_idx', 'buffer');` to actively load the index into the buffer, this can significantly improve the search speed.  And when the load enters the buffer, cleaning the cache will not significantly reduce the search speed. This may be because the memory corresponding to the buffer is occupied by postgres and will not be cleared.
Here's what it looked like on my device:

- hnsw.ef_search=10,   Latency (p99)=0.125s
- hnsw.ef_search=40,   Latency (p99)=0.409s
- hnsw.ef_search=100, Latency (p99)=0.831s
- hnsw.ef_search=200, Latency (p99)=1.414s
- hnsw.ef_search=500, Latency (p99)=2.998s

I found that the three indexes of vector cosine ops, halfvec cosine ops, and binary quantization only have obvious differences in memory. There is no obvious difference in speed after loading the index. Even binary quantization requires rerank and is a little slower.
And here's part of my config:
```
shared_buffers = 4GB
effective_cache_size = 4GB
maintenance_work_mem = 1GB
wal_buffers = 16MB
work_mem = 10922kB
```
On my device, I can't seem to allocate more memory to shared_buffers, because I have other applications running.
From the results, I want to keep the search time at the millisecond level, but it seems that only less than 100 data can be returned.
Is there a problem with my approach? Are there other ways to increase the search speed?

view thread (8+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-666-c2335020811@github.com>
Permalink:  ../gh-pgvector-pgvector-666-c2335020811@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox