aboutsummaryrefslogtreecommitdiff
path: root/src/include/commands/progress.h
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2019-04-02 15:18:08 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2019-04-02 15:18:08 -0300
commitab0dfc961b6a821f23d9c40c723d11380ce195a6 (patch)
tree106f18249990aa4da0e3e49a9bf957b8a42f34e5 /src/include/commands/progress.h
parent4d0e994eed83c845a05da6e9a417b4efec67efaf (diff)
downloadpostgresql-ab0dfc961b6a821f23d9c40c723d11380ce195a6.tar.gz
postgresql-ab0dfc961b6a821f23d9c40c723d11380ce195a6.zip
Report progress of CREATE INDEX operations
This uses the progress reporting infrastructure added by c16dc1aca5e0, adding support for CREATE INDEX and CREATE INDEX CONCURRENTLY. There are two pieces to this: one is index-AM-agnostic, and the other is AM-specific. The latter is fairly elaborate for btrees, including reportage for parallel index builds and the separate phases that btree index creation uses; other index AMs, which are much simpler in their building procedures, have simplistic reporting only, but that seems sufficient, at least for non-concurrent builds. The index-AM-agnostic part is fairly complete, providing insight into the CONCURRENTLY wait phases as well as block-based progress during the index validation table scan. (The index validation index scan requires patching each AM, which has not been included here.) Reviewers: Rahila Syed, Pavan Deolasee, Tatsuro Yamada Discussion: https://postgr.es/m/20181220220022.mg63bhk26zdpvmcj@alvherre.pgsql
Diffstat (limited to 'src/include/commands/progress.h')
-rw-r--r--src/include/commands/progress.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/include/commands/progress.h b/src/include/commands/progress.h
index 04542d9e923..f046fa13b18 100644
--- a/src/include/commands/progress.h
+++ b/src/include/commands/progress.h
@@ -44,7 +44,7 @@
#define PROGRESS_CLUSTER_HEAP_BLKS_SCANNED 6
#define PROGRESS_CLUSTER_INDEX_REBUILD_COUNT 7
-/* Phases of cluster (as dvertised via PROGRESS_CLUSTER_PHASE) */
+/* Phases of cluster (as advertised via PROGRESS_CLUSTER_PHASE) */
#define PROGRESS_CLUSTER_PHASE_SEQ_SCAN_HEAP 1
#define PROGRESS_CLUSTER_PHASE_INDEX_SCAN_HEAP 2
#define PROGRESS_CLUSTER_PHASE_SORT_TUPLES 3
@@ -57,4 +57,39 @@
#define PROGRESS_CLUSTER_COMMAND_CLUSTER 1
#define PROGRESS_CLUSTER_COMMAND_VACUUM_FULL 2
+/* Progress parameters for CREATE INDEX */
+/* 3, 4 and 5 reserved for "waitfor" metrics */
+#define PROGRESS_CREATEIDX_ACCESS_METHOD_OID 8
+#define PROGRESS_CREATEIDX_PHASE 9 /* AM-agnostic phase # */
+#define PROGRESS_CREATEIDX_SUBPHASE 10 /* phase # filled by AM */
+#define PROGRESS_CREATEIDX_TUPLES_TOTAL 11
+#define PROGRESS_CREATEIDX_TUPLES_DONE 12
+#define PROGRESS_CREATEIDX_PARTITIONS_TOTAL 13
+#define PROGRESS_CREATEIDX_PARTITIONS_DONE 14
+/* 15 and 16 reserved for "block number" metrics */
+
+/* Phases of CREATE INDEX (as advertised via PROGRESS_CREATEIDX_PHASE) */
+#define PROGRESS_CREATEIDX_PHASE_WAIT_1 1
+#define PROGRESS_CREATEIDX_PHASE_BUILD 2
+#define PROGRESS_CREATEIDX_PHASE_WAIT_2 3
+#define PROGRESS_CREATEIDX_PHASE_VALIDATE_IDXSCAN 4
+#define PROGRESS_CREATEIDX_PHASE_VALIDATE_SORT 5
+#define PROGRESS_CREATEIDX_PHASE_VALIDATE_TABLESCAN 6
+#define PROGRESS_CREATEIDX_PHASE_WAIT_3 7
+
+/*
+ * Subphases of CREATE INDEX, for index_build.
+ */
+#define PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE 1
+/* Additional phases are defined by each AM */
+
+/* Lock holder wait counts */
+#define PROGRESS_WAITFOR_TOTAL 3
+#define PROGRESS_WAITFOR_DONE 4
+#define PROGRESS_WAITFOR_CURRENT_PID 5
+
+/* Block numbers in a generic relation scan */
+#define PROGRESS_SCAN_BLOCKS_TOTAL 15
+#define PROGRESS_SCAN_BLOCKS_DONE 16
+
#endif