Skip to content

Prefetch since v0.4.0

The default prefetch setting dramatically accelerates queries on large datasets by loading the necessary data from the disk into the memory cache before it is needed. It minimizes disk I/O latency during queries, allowing users to enjoy optimal performance with no configuration necessary.

Prefetch Mode

TIP

This feature is enabled by default. Any query can be benefit from prefetching with VectorChord v0.4.0 and later versions.

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.

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 faster than the previous behavior in most cases, read_buffer.

They can be set by vchordrq.io_rerank and vchordrq.io_search:

Prefetch ModeDescriptionSupported on PG Version
read_streamAdvanced streaming prefetch by streaming I/O APIPostgreSQL 17
prefetch_bufferSimple prefetching using PostgreSQL's buffer prefetch mechanismPostgreSQL 13, 14, 15, 16, 17
read_bufferBasic buffer reading without prefetchingPostgreSQL 13, 14, 15, 16, 17

If you are using PostgreSQL 16 or an earlier version, the prefetch_buffer can also help you.

Furthermore, the Asynchronous I/O that will be introduced 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:

Prefetch modes