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  * pgstat.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-2020, 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_TUPLES 5
27 #define PROGRESS_VACUUM_NUM_DEAD_TUPLES 6
28 
29 /* Phases of vacuum (as advertised via PROGRESS_VACUUM_PHASE) */
30 #define PROGRESS_VACUUM_PHASE_SCAN_HEAP 1
31 #define PROGRESS_VACUUM_PHASE_VACUUM_INDEX 2
32 #define PROGRESS_VACUUM_PHASE_VACUUM_HEAP 3
33 #define PROGRESS_VACUUM_PHASE_INDEX_CLEANUP 4
34 #define PROGRESS_VACUUM_PHASE_TRUNCATE 5
35 #define PROGRESS_VACUUM_PHASE_FINAL_CLEANUP 6
36 
37 /* Progress parameters for analyze */
38 #define PROGRESS_ANALYZE_PHASE 0
39 #define PROGRESS_ANALYZE_BLOCKS_TOTAL 1
40 #define PROGRESS_ANALYZE_BLOCKS_DONE 2
41 #define PROGRESS_ANALYZE_EXT_STATS_TOTAL 3
42 #define PROGRESS_ANALYZE_EXT_STATS_COMPUTED 4
43 #define PROGRESS_ANALYZE_CHILD_TABLES_TOTAL 5
44 #define PROGRESS_ANALYZE_CHILD_TABLES_DONE 6
45 #define PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID 7
46 
47 /* Phases of analyze (as advertised via PROGRESS_ANALYZE_PHASE) */
48 #define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS 1
49 #define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS_INH 2
50 #define PROGRESS_ANALYZE_PHASE_COMPUTE_STATS 3
51 #define PROGRESS_ANALYZE_PHASE_COMPUTE_EXT_STATS 4
52 #define PROGRESS_ANALYZE_PHASE_FINALIZE_ANALYZE 5
53 
54 /* Progress parameters for cluster */
55 #define PROGRESS_CLUSTER_COMMAND 0
56 #define PROGRESS_CLUSTER_PHASE 1
57 #define PROGRESS_CLUSTER_INDEX_RELID 2
58 #define PROGRESS_CLUSTER_HEAP_TUPLES_SCANNED 3
59 #define PROGRESS_CLUSTER_HEAP_TUPLES_WRITTEN 4
60 #define PROGRESS_CLUSTER_TOTAL_HEAP_BLKS 5
61 #define PROGRESS_CLUSTER_HEAP_BLKS_SCANNED 6
62 #define PROGRESS_CLUSTER_INDEX_REBUILD_COUNT 7
63 
64 /* Phases of cluster (as advertised via PROGRESS_CLUSTER_PHASE) */
65 #define PROGRESS_CLUSTER_PHASE_SEQ_SCAN_HEAP 1
66 #define PROGRESS_CLUSTER_PHASE_INDEX_SCAN_HEAP 2
67 #define PROGRESS_CLUSTER_PHASE_SORT_TUPLES 3
68 #define PROGRESS_CLUSTER_PHASE_WRITE_NEW_HEAP 4
69 #define PROGRESS_CLUSTER_PHASE_SWAP_REL_FILES 5
70 #define PROGRESS_CLUSTER_PHASE_REBUILD_INDEX 6
71 #define PROGRESS_CLUSTER_PHASE_FINAL_CLEANUP 7
72 
73 /* Commands of PROGRESS_CLUSTER */
74 #define PROGRESS_CLUSTER_COMMAND_CLUSTER 1
75 #define PROGRESS_CLUSTER_COMMAND_VACUUM_FULL 2
76 
77 /* Progress parameters for CREATE INDEX */
78 /* 3, 4 and 5 reserved for "waitfor" metrics */
79 #define PROGRESS_CREATEIDX_COMMAND 0
80 #define PROGRESS_CREATEIDX_INDEX_OID 6
81 #define PROGRESS_CREATEIDX_ACCESS_METHOD_OID 8
82 #define PROGRESS_CREATEIDX_PHASE 9 /* AM-agnostic phase # */
83 #define PROGRESS_CREATEIDX_SUBPHASE 10 /* phase # filled by AM */
84 #define PROGRESS_CREATEIDX_TUPLES_TOTAL 11
85 #define PROGRESS_CREATEIDX_TUPLES_DONE 12
86 #define PROGRESS_CREATEIDX_PARTITIONS_TOTAL 13
87 #define PROGRESS_CREATEIDX_PARTITIONS_DONE 14
88 /* 15 and 16 reserved for "block number" metrics */
89 
90 /* Phases of CREATE INDEX (as advertised via PROGRESS_CREATEIDX_PHASE) */
91 #define PROGRESS_CREATEIDX_PHASE_WAIT_1 1
92 #define PROGRESS_CREATEIDX_PHASE_BUILD 2
93 #define PROGRESS_CREATEIDX_PHASE_WAIT_2 3
94 #define PROGRESS_CREATEIDX_PHASE_VALIDATE_IDXSCAN 4
95 #define PROGRESS_CREATEIDX_PHASE_VALIDATE_SORT 5
96 #define PROGRESS_CREATEIDX_PHASE_VALIDATE_TABLESCAN 6
97 #define PROGRESS_CREATEIDX_PHASE_WAIT_3 7
98 #define PROGRESS_CREATEIDX_PHASE_WAIT_4 8
99 #define PROGRESS_CREATEIDX_PHASE_WAIT_5 9
100 
101 /*
102  * Subphases of CREATE INDEX, for index_build.
103  */
104 #define PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE 1
105 /* Additional phases are defined by each AM */
106 
107 /* Commands of PROGRESS_CREATEIDX */
108 #define PROGRESS_CREATEIDX_COMMAND_CREATE 1
109 #define PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY 2
110 #define PROGRESS_CREATEIDX_COMMAND_REINDEX 3
111 #define PROGRESS_CREATEIDX_COMMAND_REINDEX_CONCURRENTLY 4
112 
113 /* Lock holder wait counts */
114 #define PROGRESS_WAITFOR_TOTAL 3
115 #define PROGRESS_WAITFOR_DONE 4
116 #define PROGRESS_WAITFOR_CURRENT_PID 5
117 
118 /* Block numbers in a generic relation scan */
119 #define PROGRESS_SCAN_BLOCKS_TOTAL 15
120 #define PROGRESS_SCAN_BLOCKS_DONE 16
121 
122 #endif