PostgreSQL Source Code  git master
read_stream.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * read_stream.h
4  * Mechanism for accessing buffered relation data with look-ahead
5  *
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/storage/read_stream.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef READ_STREAM_H
15 #define READ_STREAM_H
16 
17 #include "storage/bufmgr.h"
18 
19 /* Default tuning, reasonable for many users. */
20 #define READ_STREAM_DEFAULT 0x00
21 
22 /*
23  * I/O streams that are performing maintenance work on behalf of potentially
24  * many users, and thus should be governed by maintenance_io_concurrency
25  * instead of effective_io_concurrency. For example, VACUUM or CREATE INDEX.
26  */
27 #define READ_STREAM_MAINTENANCE 0x01
28 
29 /*
30  * We usually avoid issuing prefetch advice automatically when sequential
31  * access is detected, but this flag explicitly disables it, for cases that
32  * might not be correctly detected. Explicit advice is known to perform worse
33  * than letting the kernel (at least Linux) detect sequential access.
34  */
35 #define READ_STREAM_SEQUENTIAL 0x02
36 
37 /*
38  * We usually ramp up from smaller reads to larger ones, to support users who
39  * don't know if it's worth reading lots of buffers yet. This flag disables
40  * that, declaring ahead of time that we'll be reading all available buffers.
41  */
42 #define READ_STREAM_FULL 0x04
43 
44 struct ReadStream;
45 typedef struct ReadStream ReadStream;
46 
47 /* Callback that returns the next block number to read. */
50  void *per_buffer_data);
51 
52 extern ReadStream *read_stream_begin_relation(int flags,
53  BufferAccessStrategy strategy,
54  Relation rel,
55  ForkNumber forknum,
58  size_t per_buffer_data_size);
59 extern Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_private);
60 extern void read_stream_reset(ReadStream *stream);
61 extern void read_stream_end(ReadStream *stream);
62 
63 #endif /* READ_STREAM_H */
uint32 BlockNumber
Definition: block.h:31
int Buffer
Definition: buf.h:23
Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_private)
Definition: read_stream.c:570
ReadStream * read_stream_begin_relation(int flags, BufferAccessStrategy strategy, Relation rel, ForkNumber forknum, ReadStreamBlockNumberCB callback, void *callback_private_data, size_t per_buffer_data_size)
Definition: read_stream.c:410
void read_stream_reset(ReadStream *stream)
Definition: read_stream.c:773
void read_stream_end(ReadStream *stream)
Definition: read_stream.c:800
BlockNumber(* ReadStreamBlockNumberCB)(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
Definition: read_stream.h:48
ForkNumber
Definition: relpath.h:48
void * per_buffer_data
Definition: read_stream.c:144
size_t per_buffer_data_size
Definition: read_stream.c:143
void * callback_private_data
Definition: read_stream.c:133
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46