PostgreSQL Source Code git master
instrument_node.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * instrument_node.h
4 * Definitions for node-specific support for parallel query instrumentation
5 *
6 * These structs purposely contain no pointers because they are copied
7 * across processes during parallel query execution. Each worker copies its
8 * individual information into the container struct at executor shutdown time,
9 * to allow the leader to display the information in EXPLAIN ANALYZE.
10 *
11 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1994, Regents of the University of California
13 *
14 * src/include/executor/instrument_node.h
15 *
16 *-------------------------------------------------------------------------
17 */
18#ifndef INSTRUMENT_NODE_H
19#define INSTRUMENT_NODE_H
20
21
22/* ---------------------
23 * Instrumentation information for aggregate function execution
24 * ---------------------
25 */
27{
28 Size hash_mem_peak; /* peak hash table memory usage */
29 uint64 hash_disk_used; /* kB of disk space used */
30 int hash_batches_used; /* batches used during entire execution */
32
33/*
34 * Shared memory container for per-worker aggregate information
35 */
36typedef struct SharedAggInfo
37{
41
42
43/* ---------------------
44 * Instrumentation information for indexscans (amgettuple and amgetbitmap)
45 * ---------------------
46 */
48{
49 /* Index search count (incremented with pgstat_count_index_scan call) */
52
53/*
54 * Shared memory container for per-worker information
55 */
57{
61
62
63/* ---------------------
64 * Instrumentation information for bitmap heap scans
65 *
66 * exact_pages total number of exact pages retrieved
67 * lossy_pages total number of lossy pages retrieved
68 * ---------------------
69 */
71{
75
76/*
77 * Shared memory container for per-worker information
78 */
80{
84
85
86/* ---------------------
87 * Instrumentation information for Memoize
88 * ---------------------
89 */
91{
92 uint64 cache_hits; /* number of rescans where we've found the
93 * scan parameters values to be cached */
94 uint64 cache_misses; /* number of rescans where we've not found the
95 * scan parameters values to be cached */
96 uint64 cache_evictions; /* number of cache entries removed due to
97 * the need to free memory */
98 uint64 cache_overflows; /* number of times we've had to bypass the
99 * cache when filling it due to not being
100 * able to free enough space to store the
101 * current scan's tuples */
102 uint64 mem_peak; /* peak memory usage in bytes */
104
105/*
106 * Shared memory container for per-worker memoize information
107 */
108typedef struct SharedMemoizeInfo
109{
113
114
115/* ---------------------
116 * Instrumentation information for Sorts.
117 * ---------------------
118 */
119
120typedef enum
121{
125
126/*
127 * The parallel-sort infrastructure relies on having a zero TuplesortMethod
128 * to indicate that a worker never did anything, so we assign zero to
129 * SORT_TYPE_STILL_IN_PROGRESS. The other values of this enum can be
130 * OR'ed together to represent a situation where different workers used
131 * different methods, so we need a separate bit for each one. Keep the
132 * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
133 */
134typedef enum
135{
142#define NUM_TUPLESORTMETHODS 4
143
145{
146 TuplesortMethod sortMethod; /* sort algorithm used */
147 TuplesortSpaceType spaceType; /* type of space spaceUsed represents */
148 int64 spaceUsed; /* space consumption, in kB */
150
151/*
152 * Shared memory container for per-worker sort information
153 */
154typedef struct SharedSortInfo
155{
159
160
161/* ---------------------
162 * Instrumentation information for nodeHash.c
163 * ---------------------
164 */
166{
167 int nbuckets; /* number of buckets at end of execution */
168 int nbuckets_original; /* planned number of buckets */
169 int nbatch; /* number of batches at end of execution */
170 int nbatch_original; /* planned number of batches */
171 Size space_peak; /* peak memory usage in bytes */
173
174/*
175 * Shared memory container for per-worker information
176 */
177typedef struct SharedHashInfo
178{
182
183
184/* ---------------------
185 * Instrumentation information for IncrementalSort
186 * ---------------------
187 */
189{
195 bits32 sortMethods; /* bitmask of TuplesortMethod */
197
199{
203
204/* Shared memory container for per-worker incremental sort information */
206{
210
211#endif /* INSTRUMENT_NODE_H */
int64_t int64
Definition: c.h:549
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:486
uint32 bits32
Definition: c.h:561
uint64_t uint64
Definition: c.h:553
size_t Size
Definition: c.h:625
struct SharedIncrementalSortInfo SharedIncrementalSortInfo
struct SharedMemoizeInfo SharedMemoizeInfo
struct IncrementalSortInfo IncrementalSortInfo
struct MemoizeInstrumentation MemoizeInstrumentation
struct SharedBitmapHeapInstrumentation SharedBitmapHeapInstrumentation
struct BitmapHeapScanInstrumentation BitmapHeapScanInstrumentation
struct IndexScanInstrumentation IndexScanInstrumentation
struct SharedSortInfo SharedSortInfo
struct AggregateInstrumentation AggregateInstrumentation
struct SharedHashInfo SharedHashInfo
struct TuplesortInstrumentation TuplesortInstrumentation
TuplesortSpaceType
@ SORT_SPACE_TYPE_DISK
@ SORT_SPACE_TYPE_MEMORY
struct HashInstrumentation HashInstrumentation
TuplesortMethod
@ SORT_TYPE_EXTERNAL_SORT
@ SORT_TYPE_TOP_N_HEAPSORT
@ SORT_TYPE_QUICKSORT
@ SORT_TYPE_STILL_IN_PROGRESS
@ SORT_TYPE_EXTERNAL_MERGE
struct IncrementalSortGroupInfo IncrementalSortGroupInfo
struct SharedAggInfo SharedAggInfo
struct SharedIndexScanInstrumentation SharedIndexScanInstrumentation
IncrementalSortGroupInfo prefixsortGroupInfo
IncrementalSortGroupInfo fullsortGroupInfo
AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
BitmapHeapScanInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER]
IncrementalSortInfo sinfo[FLEXIBLE_ARRAY_MEMBER]
IndexScanInstrumentation winstrument[FLEXIBLE_ARRAY_MEMBER]
MemoizeInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
TuplesortInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
TuplesortMethod sortMethod
TuplesortSpaceType spaceType