PostgreSQL Source Code  git master
progress.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * progress.h
4  * Constants used with the progress reporting facilities defined in
5  * backend_status.h. These are possibly interesting to extensions, so we
6  * expose them via this header file. Note that if you update these
7  * constants, you probably also need to update the views based on them
8  * in system_views.sql.
9  *
10  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
11  * Portions Copyright (c) 1994, Regents of the University of California
12  *
13  * src/include/commands/progress.h
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef PROGRESS_H
18 #define PROGRESS_H
19 
20 /* Progress parameters for (lazy) vacuum */
21 #define PROGRESS_VACUUM_PHASE 0
22 #define PROGRESS_VACUUM_TOTAL_HEAP_BLKS 1
23 #define PROGRESS_VACUUM_HEAP_BLKS_SCANNED 2
24 #define PROGRESS_VACUUM_HEAP_BLKS_VACUUMED 3
25 #define PROGRESS_VACUUM_NUM_INDEX_VACUUMS 4
26 #define PROGRESS_VACUUM_MAX_DEAD_TUPLE_BYTES 5
27 #define PROGRESS_VACUUM_DEAD_TUPLE_BYTES 6
28 #define PROGRESS_VACUUM_NUM_DEAD_ITEM_IDS 7
29 #define PROGRESS_VACUUM_INDEXES_TOTAL 8
30 #define PROGRESS_VACUUM_INDEXES_PROCESSED 9
31 
32 /* Phases of vacuum (as advertised via PROGRESS_VACUUM_PHASE) */
33 #define PROGRESS_VACUUM_PHASE_SCAN_HEAP 1
34 #define PROGRESS_VACUUM_PHASE_VACUUM_INDEX 2
35 #define PROGRESS_VACUUM_PHASE_VACUUM_HEAP 3
36 #define PROGRESS_VACUUM_PHASE_INDEX_CLEANUP 4
37 #define PROGRESS_VACUUM_PHASE_TRUNCATE 5
38 #define PROGRESS_VACUUM_PHASE_FINAL_CLEANUP 6
39 
40 /* Progress parameters for analyze */
41 #define PROGRESS_ANALYZE_PHASE 0
42 #define PROGRESS_ANALYZE_BLOCKS_TOTAL 1
43 #define PROGRESS_ANALYZE_BLOCKS_DONE 2
44 #define PROGRESS_ANALYZE_EXT_STATS_TOTAL 3
45 #define PROGRESS_ANALYZE_EXT_STATS_COMPUTED 4
46 #define PROGRESS_ANALYZE_CHILD_TABLES_TOTAL 5
47 #define PROGRESS_ANALYZE_CHILD_TABLES_DONE 6
48 #define PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID 7
49 
50 /* Phases of analyze (as advertised via PROGRESS_ANALYZE_PHASE) */
51 #define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS 1
52 #define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS_INH 2
53 #define PROGRESS_ANALYZE_PHASE_COMPUTE_STATS 3
54 #define PROGRESS_ANALYZE_PHASE_COMPUTE_EXT_STATS 4
55 #define PROGRESS_ANALYZE_PHASE_FINALIZE_ANALYZE 5
56 
57 /* Progress parameters for cluster */
58 #define PROGRESS_CLUSTER_COMMAND 0
59 #define PROGRESS_CLUSTER_PHASE 1
60 #define PROGRESS_CLUSTER_INDEX_RELID 2
61 #define PROGRESS_CLUSTER_HEAP_TUPLES_SCANNED 3
62 #define PROGRESS_CLUSTER_HEAP_TUPLES_WRITTEN 4
63 #define PROGRESS_CLUSTER_TOTAL_HEAP_BLKS 5
64 #define PROGRESS_CLUSTER_HEAP_BLKS_SCANNED 6
65 #define PROGRESS_CLUSTER_INDEX_REBUILD_COUNT 7
66 
67 /* Phases of cluster (as advertised via PROGRESS_CLUSTER_PHASE) */
68 #define PROGRESS_CLUSTER_PHASE_SEQ_SCAN_HEAP 1
69 #define PROGRESS_CLUSTER_PHASE_INDEX_SCAN_HEAP 2
70 #define PROGRESS_CLUSTER_PHASE_SORT_TUPLES 3
71 #define PROGRESS_CLUSTER_PHASE_WRITE_NEW_HEAP 4
72 #define PROGRESS_CLUSTER_PHASE_SWAP_REL_FILES 5
73 #define PROGRESS_CLUSTER_PHASE_REBUILD_INDEX 6
74 #define PROGRESS_CLUSTER_PHASE_FINAL_CLEANUP 7
75 
76 /* Commands of PROGRESS_CLUSTER */
77 #define PROGRESS_CLUSTER_COMMAND_CLUSTER 1
78 #define PROGRESS_CLUSTER_COMMAND_VACUUM_FULL 2
79 
80 /* Progress parameters for CREATE INDEX */
81 /* 3, 4 and 5 reserved for "waitfor" metrics */
82 #define PROGRESS_CREATEIDX_COMMAND 0
83 #define PROGRESS_CREATEIDX_INDEX_OID 6
84 #define PROGRESS_CREATEIDX_ACCESS_METHOD_OID 8
85 #define PROGRESS_CREATEIDX_PHASE 9 /* AM-agnostic phase # */
86 #define PROGRESS_CREATEIDX_SUBPHASE 10 /* phase # filled by AM */
87 #define PROGRESS_CREATEIDX_TUPLES_TOTAL 11
88 #define PROGRESS_CREATEIDX_TUPLES_DONE 12
89 #define PROGRESS_CREATEIDX_PARTITIONS_TOTAL 13
90 #define PROGRESS_CREATEIDX_PARTITIONS_DONE 14
91 /* 15 and 16 reserved for "block number" metrics */
92 
93 /* Phases of CREATE INDEX (as advertised via PROGRESS_CREATEIDX_PHASE) */
94 #define PROGRESS_CREATEIDX_PHASE_WAIT_1 1
95 #define PROGRESS_CREATEIDX_PHASE_BUILD 2
96 #define PROGRESS_CREATEIDX_PHASE_WAIT_2 3
97 #define PROGRESS_CREATEIDX_PHASE_VALIDATE_IDXSCAN 4
98 #define PROGRESS_CREATEIDX_PHASE_VALIDATE_SORT 5
99 #define PROGRESS_CREATEIDX_PHASE_VALIDATE_TABLESCAN 6
100 #define PROGRESS_CREATEIDX_PHASE_WAIT_3 7
101 #define PROGRESS_CREATEIDX_PHASE_WAIT_4 8
102 #define PROGRESS_CREATEIDX_PHASE_WAIT_5 9
103 
104 /*
105  * Subphases of CREATE INDEX, for index_build.
106  */
107 #define PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE 1
108 /* Additional phases are defined by each AM */
109 
110 /* Commands of PROGRESS_CREATEIDX */
111 #define PROGRESS_CREATEIDX_COMMAND_CREATE 1
112 #define PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY 2
113 #define PROGRESS_CREATEIDX_COMMAND_REINDEX 3
114 #define PROGRESS_CREATEIDX_COMMAND_REINDEX_CONCURRENTLY 4
115 
116 /* Lock holder wait counts */
117 #define PROGRESS_WAITFOR_TOTAL 3
118 #define PROGRESS_WAITFOR_DONE 4
119 #define PROGRESS_WAITFOR_CURRENT_PID 5
120 
121 /* Block numbers in a generic relation scan */
122 #define PROGRESS_SCAN_BLOCKS_TOTAL 15
123 #define PROGRESS_SCAN_BLOCKS_DONE 16
124 
125 /* Progress parameters for pg_basebackup */
126 #define PROGRESS_BASEBACKUP_PHASE 0
127 #define PROGRESS_BASEBACKUP_BACKUP_TOTAL 1
128 #define PROGRESS_BASEBACKUP_BACKUP_STREAMED 2
129 #define PROGRESS_BASEBACKUP_TBLSPC_TOTAL 3
130 #define PROGRESS_BASEBACKUP_TBLSPC_STREAMED 4
131 
132 /* Phases of pg_basebackup (as advertised via PROGRESS_BASEBACKUP_PHASE) */
133 #define PROGRESS_BASEBACKUP_PHASE_WAIT_CHECKPOINT 1
134 #define PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE 2
135 #define PROGRESS_BASEBACKUP_PHASE_STREAM_BACKUP 3
136 #define PROGRESS_BASEBACKUP_PHASE_WAIT_WAL_ARCHIVE 4
137 #define PROGRESS_BASEBACKUP_PHASE_TRANSFER_WAL 5
138 
139 /* Progress parameters for PROGRESS_COPY */
140 #define PROGRESS_COPY_BYTES_PROCESSED 0
141 #define PROGRESS_COPY_BYTES_TOTAL 1
142 #define PROGRESS_COPY_TUPLES_PROCESSED 2
143 #define PROGRESS_COPY_TUPLES_EXCLUDED 3
144 #define PROGRESS_COPY_COMMAND 4
145 #define PROGRESS_COPY_TYPE 5
146 #define PROGRESS_COPY_TUPLES_SKIPPED 6
147 
148 /* Commands of COPY (as advertised via PROGRESS_COPY_COMMAND) */
149 #define PROGRESS_COPY_COMMAND_FROM 1
150 #define PROGRESS_COPY_COMMAND_TO 2
151 
152 /* Types of COPY commands (as advertised via PROGRESS_COPY_TYPE) */
153 #define PROGRESS_COPY_TYPE_FILE 1
154 #define PROGRESS_COPY_TYPE_PROGRAM 2
155 #define PROGRESS_COPY_TYPE_PIPE 3
156 #define PROGRESS_COPY_TYPE_CALLBACK 4
157 
158 #endif