summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-02-22 14:21:40 +0900
committerMichael Paquier <michael@paquier.xyz>2021-02-22 14:21:40 +0900
commit92942642788c9d73e4c090ee0a77603f7afbc1d7 (patch)
tree259cc5c395ef664a0a8c542b1aa9a39c5a452615 /src
parentdb8374d804f2dd35a0f934984d1d3686cc71f545 (diff)
downloadpostgresql-92942642788c9d73e4c090ee0a77603f7afbc1d7.tar.gz
Use pgstat_progress_update_multi_param() where possible
This commit changes one code path in REINDEX INDEX and one code path in CREATE INDEX CONCURRENTLY to report the progress of each operation using pgstat_progress_update_multi_param() rather than multiple calls to pgstat_progress_update_param(). This has the advantage to make the progress report more consistent to the end-user without impacting the amount of information provided. Author: Bharath Rupireddy Discussion: https://postgr.es/m/CALj2ACV5zW7GxD8D_tyO==bcj6ZktQchEKWKPBOAGKiLhAQo=w@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/index.c14
-rw-r--r--src/backend/commands/indexcmds.c19
2 files changed, 24 insertions, 9 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index b4ab0b88ad..ea22256819 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -3686,12 +3686,18 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
if (progress)
{
+ const int progress_cols[] = {
+ PROGRESS_CREATEIDX_COMMAND,
+ PROGRESS_CREATEIDX_INDEX_OID
+ };
+ const int64 progress_vals[] = {
+ PROGRESS_CREATEIDX_COMMAND_REINDEX,
+ indexId
+ };
+
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
heapId);
- pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
- PROGRESS_CREATEIDX_COMMAND_REINDEX);
- pgstat_progress_update_param(PROGRESS_CREATEIDX_INDEX_OID,
- indexId);
+ pgstat_progress_update_multi_param(2, progress_cols, progress_vals);
}
/*
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index e1bed087d7..8bc652ecd3 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -1457,10 +1457,21 @@ DefineIndex(Oid relationId,
set_indexsafe_procflags();
/*
- * The index is now visible, so we can report the OID.
+ * The index is now visible, so we can report the OID. While on it,
+ * include the report for the beginning of phase 2.
*/
- pgstat_progress_update_param(PROGRESS_CREATEIDX_INDEX_OID,
- indexRelationId);
+ {
+ const int progress_cols[] = {
+ PROGRESS_CREATEIDX_INDEX_OID,
+ PROGRESS_CREATEIDX_PHASE
+ };
+ const int64 progress_vals[] = {
+ indexRelationId,
+ PROGRESS_CREATEIDX_PHASE_WAIT_1
+ };
+
+ pgstat_progress_update_multi_param(2, progress_cols, progress_vals);
+ }
/*
* Phase 2 of concurrent index build (see comments for validate_index()
@@ -1478,8 +1489,6 @@ DefineIndex(Oid relationId,
* exclusive lock on our table. The lock code will detect deadlock and
* error out properly.
*/
- pgstat_progress_update_param(PROGRESS_CREATEIDX_PHASE,
- PROGRESS_CREATEIDX_PHASE_WAIT_1);
WaitForLockers(heaplocktag, ShareLock, true);
/*