Skip to content

Commit 9294264

Browse files
committed
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
1 parent db8374d commit 9294264

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/backend/catalog/index.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,12 +3686,18 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
36863686

36873687
if (progress)
36883688
{
3689+
const int progress_cols[] = {
3690+
PROGRESS_CREATEIDX_COMMAND,
3691+
PROGRESS_CREATEIDX_INDEX_OID
3692+
};
3693+
const int64 progress_vals[] = {
3694+
PROGRESS_CREATEIDX_COMMAND_REINDEX,
3695+
indexId
3696+
};
3697+
36893698
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
36903699
heapId);
3691-
pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
3692-
PROGRESS_CREATEIDX_COMMAND_REINDEX);
3693-
pgstat_progress_update_param(PROGRESS_CREATEIDX_INDEX_OID,
3694-
indexId);
3700+
pgstat_progress_update_multi_param(2, progress_cols, progress_vals);
36953701
}
36963702

36973703
/*

src/backend/commands/indexcmds.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,10 +1457,21 @@ DefineIndex(Oid relationId,
14571457
set_indexsafe_procflags();
14581458

14591459
/*
1460-
* The index is now visible, so we can report the OID.
1460+
* The index is now visible, so we can report the OID. While on it,
1461+
* include the report for the beginning of phase 2.
14611462
*/
1462-
pgstat_progress_update_param(PROGRESS_CREATEIDX_INDEX_OID,
1463-
indexRelationId);
1463+
{
1464+
const int progress_cols[] = {
1465+
PROGRESS_CREATEIDX_INDEX_OID,
1466+
PROGRESS_CREATEIDX_PHASE
1467+
};
1468+
const int64 progress_vals[] = {
1469+
indexRelationId,
1470+
PROGRESS_CREATEIDX_PHASE_WAIT_1
1471+
};
1472+
1473+
pgstat_progress_update_multi_param(2, progress_cols, progress_vals);
1474+
}
14641475

14651476
/*
14661477
* Phase 2 of concurrent index build (see comments for validate_index()
@@ -1478,8 +1489,6 @@ DefineIndex(Oid relationId,
14781489
* exclusive lock on our table. The lock code will detect deadlock and
14791490
* error out properly.
14801491
*/
1481-
pgstat_progress_update_param(PROGRESS_CREATEIDX_PHASE,
1482-
PROGRESS_CREATEIDX_PHASE_WAIT_1);
14831492
WaitForLockers(heaplocktag, ShareLock, true);
14841493

14851494
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy