Prefetch since v0.4.0
Prefetch dramatically accelerates large dataset operations by loading data from disk into memory cache before it's needed. It minimizes disk I/O latency during queries, transforming slow disk access into lightning-fast memory operations for optimal query performance.
PostgreSQL 17 has introduced a new streaming I/O API for more efficient sequential I/O. Take advantage of it, a sequential scan on a table will be much faster.
Prefetch Mode
TIP
This feature is enabled by default. Any query can be benefit from prefetching with VectorChord v0.4.0
and later versions.
In VectorChord, we implemented two prefetch methods: A simple one, prefetch_buffer
, and read_stream
, which uses the streaming I/O API. Both methods are much faster than the previous behavior, read_buffer
.
They can be set by vchordrq.io_rerank and vchordrq.io_search:
Prefetch Mode | Description | Supported on PG Version |
---|---|---|
read_stream | Advanced streaming prefetch by streaming I/O API | PostgreSQL 17+ only |
prefetch_buffer | Simple prefetching using PostgreSQL's buffer prefetch mechanism | Any |
read_buffer | Basic buffer reading without prefetching | Any |
If you are using PostgreSQL 16 or an earlier version, the prefetch_buffer
can also help you.
Furthermore, the Asynchronous I/O which will in PostgreSQL 18 will make read_stream
more advantageous.
Based on our experimental results, the first query latency can be reduced by 2-3 times with prefetch:

See also: Indexing Prewarm