pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #962: Why so many I/O reads when index is in shared_buffers?
3+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #962: Why so many I/O reads when index is in shared_buffers?
@ 2026-03-05 00:48  "alonziv (@alonziv)" <noreply+alonziv@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: alonziv (@alonziv) @ 2026-03-05 00:48 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

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!

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #962: Why so many I/O reads when index is in shared_buffers?
@ 2026-03-05 01:45  "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2026-03-05 01:45 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @alonziv, it needs to read the table for `idnum`, which isn't included in the index. I'd like to support [index-only scans](https://www.postgresql.org/docs/current/indexes-index-only-scans.html) at some point, but it's not currently faster due to the [current behavior of the Postgres executor](https://www.postgresql.org/message-id/flat/2ca5865b-4693-40e5-8f78-f3b45d5378fb%40iki.fi).

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #962: Why so many I/O reads when index is in shared_buffers?
@ 2026-03-05 01:45  "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2026-03-05 01:45 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-03-05 01:45 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-05 00:48 [pgvector/pgvector] issue #962: Why so many I/O reads when index is in shared_buffers? "alonziv (@alonziv)" <noreply+alonziv@github.com>
2026-03-05 01:45 ` "ankane (@ankane)" <noreply+ankane@github.com>
2026-03-05 01:45 ` "ankane (@ankane)" <noreply+ankane@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