Provide API for relation data.
authorThomas Munro <[email protected]>
Tue, 2 Apr 2024 11:17:06 +0000 (00:17 +1300)
committerThomas Munro <[email protected]>
Tue, 2 Apr 2024 11:49:46 +0000 (00:49 +1300)
commitb5a9b18cd0bc6f0124664999b31a00a264d16913
treeb992882fb23757da9e1d9f5794d8d7b5b866da1f
parent210622c60e1a9db2e2730140b8106ab57d259d15
Provide API for  relation data.

Introduce an abstraction allowing relation data to be accessed as a
stream of buffers, with an implementation that is more efficient than
the equivalent sequence of ReadBuffer() calls.

Client code supplies a callback that can say which block number it wants
next, and then consumes individual buffers one at a time from the
stream.  This division puts read_stream.c in control of how far ahead it
can see and allows it to read clusters of neigring blocks with
StartReadBuffers().  It also issues POSIX_FADV_WILLNEED advice ahead of
time when random access is detected.

Other variants of I/O stream will be proposed in future work (for
example to support recovery, whose LsnReadQueue device in
xlogprefetcher.c is a distant cousin of this code and should eventually
be replaced by this), but this basic API is sufficient for many common
executor usage patterns involving predictable access to a single fork of
a single relation.

Several es using this API are proposed separately.

This stream concept is loosely based on ideas from Andres Freund on how
we should pave the way for later work on asynchronous I/O.

Author: Thomas Munro <[email protected]>
Author: Heikki Linnakangas <[email protected]> (contributions)
Author: Melanie Plageman <[email protected]> (contributions)
Suggested-by: Andres Freund <[email protected]>
Reviewed-by: Heikki Linnakangas <[email protected]>
Reviewed-by: Melanie Plageman <[email protected]>
Reviewed-by: Nazir Bilal Yavuz <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Tested-by: Tomas Vondra <[email protected]>
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com
src/backend/storage/Makefile
src/backend/storage/aio/Makefile[new file with mode: 0644]
src/backend/storage/aio/meson.build[new file with mode: 0644]
src/backend/storage/aio/read_stream.c[new file with mode: 0644]
src/backend/storage/meson.build
src/include/storage/read_stream.h[new file with mode: 0644]
src/tools/pgindent/typedefs.list