pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: alonziv (@alonziv) <noreply+alonziv@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #962: Why so many I/O reads when index is in shared_buffers?
Date: Thu, 05 Mar 2026 00:48:17 +0000
Message-ID: <gh-pgvector-pgvector-962@github.com> (raw)

I love pgvector. Thank you for your hard work!

I have a table with ~2M rows. The only columns are the primary key and a halfvec(3584). There is a binary-quantized ivvflat index. My queries use the index, but can be quite slow. The issue seems to be I/O reads which can be quite time consuming when the pages are not in memory.

My question is: I am only returning the primary key. Does the query need to go to the table? Or just the index? I would assume just the index, but if so, why are there so many reads? My index is 1.6GB and `shared_buffers` is 30GB+.

Here is a test:

1. I reboot my database instance (AWS RDS db.m8g.4xlarge). `shared_buffers` should now be empty.

2. I load the index into shared buffers: 
`SELECT pg_prewarm('idx_ivfflat_embeddings_bit_hamming_mini');`

3. I run my query:
```
EXPLAIN (analyze, buffers, costs, settings)
SELECT "idnum"
FROM "frl_caption_embeddings_mini"
ORDER BY binary_quantize(keyword_vectorized_embeddings)::bit(3584) <~> binary_quantize('[0.008300781,…-0.0037841797]'::vector) ASC
LIMIT 20001 
```
(Yes it’s grabbing a lot of results, but I cast a wide net and then rerank.)

RESULTS:

```
  ->  Index Scan using idx_ivfflat_embeddings_bit_hamming_mini on frl_caption_embeddings_mini  (cost=499.48..202563.95 rows=2151304 width=12) (actual time=2.420..154.080 rows=12520 loops=1)
        Order By: ((binary_quantize(keyword_vectorized_embeddings))::bit(3584) <~> '101101…100'::""bit"")
        Buffers: shared hit=34286 read=29173
        I/O Timings: shared read=55.889
Settings: effective_cache_size = '32226432kB', effective_io_concurrency = '256', jit = 'off', random_page_cost = '1.1', work_mem = '32MB', search_path = 'frl, public'
```

If the entire index is in `shared_buffers`, why does it need to read 29173 pages from disk? In this case the reads were fast, but often they are quite slow and the query may take like 8s the first time it’s run. Then if I run it again, it takes .3s because there are no reads. Am I doing something wrong? My goal is to keep the index in `shared_buffers`, eliminate reads, and have fast queries.

Any insights are greatly appreciated!

view thread (3+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-962@github.com>
Permalink:  ../gh-pgvector-pgvector-962@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