From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Rahila Syed <rahilasyed90@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: monitoring CREATE INDEX [CONCURRENTLY]
Date: Fri, 22 Feb 2019 19:10:36 -0300
Message-ID: <20190222221036.GA18589@alvherre.pgsql> (raw)
In-Reply-To: <20190222215423.GA16912@alvherre.pgsql>
Hmm, looks like a very bare-bones support for hash indexes does not
require a lot of code, and gives a clear picture (you can sit all night
watching the numbers go up, instead of biting your fingernails wondering
if it'll be completed by dawn.) This part isn't 100% done -- it we
would better to have ambuildphasename support.
(I'm a bit confused about phase 5 not reporting anything for hash
indexes in CIC, though. That's part is supposed to be AM agnostic.)
I think it was a mistake to define the progress constants in one header
file commands/progress.h and the associated functions in pgstat.h. I
think it would be better to move the function decls to
commands/progress.h.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
[text/x-diff] progress-hash.patch (1.7K, ../20190222221036.GA18589@alvherre.pgsql/2-progress-hash.patch)
download | inline diff:diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.cindex fc7db5d6a13..cf7ec655044 100644--- a/src/backend/access/hash/hash.c+++ b/src/backend/access/hash/hash.c@@ -22,9 +22,11 @@
#include "access/hash_xlog.h"
#include "access/relscan.h"
#include "catalog/index.h"
+#include "commands/progress.h"
#include "commands/vacuum.h"
#include "miscadmin.h"
#include "optimizer/plancat.h"
+#include "pgstat.h"
#include "utils/builtins.h"
#include "utils/index_selfuncs.h"
#include "utils/rel.h"
@@ -160,8 +162,10 @@ hashbuild(Relation heap, Relation index, IndexInfo *indexInfo)
buildstate.heapRel = heap;
/* do the heap scan */
- reltuples = IndexBuildHeapScan(heap, index, indexInfo, true, false,+ reltuples = IndexBuildHeapScan(heap, index, indexInfo, true, true,
hashbuildCallback, (void *) &buildstate, NULL);
+ pgstat_progress_update_param(PROGRESS_CREATEIDX_TUPLES_TOTAL,+ buildstate.indtuples);
if (buildstate.spool)
{
diff --git a/src/backend/access/hash/hashsort.c b/src/backend/access/hash/hashsort.cindex 8c55436b193..00a57470a77 100644--- a/src/backend/access/hash/hashsort.c+++ b/src/backend/access/hash/hashsort.c@@ -26,7 +26,9 @@
#include "postgres.h"
#include "access/hash.h"
+#include "commands/progress.h"
#include "miscadmin.h"
+#include "pgstat.h"
#include "utils/tuplesort.h"
@@ -116,6 +118,7 @@ void
_h_indexbuild(HSpool *hspool, Relation heapRel)
{
IndexTuple itup;
+ long tups_done = 0;
#ifdef USE_ASSERT_CHECKING
uint32 hashkey = 0;
#endif
@@ -141,5 +144,8 @@ _h_indexbuild(HSpool *hspool, Relation heapRel)
#endif
_hash_doinsert(hspool->index, itup, heapRel);
++ pgstat_progress_update_param(PROGRESS_CREATEIDX_TUPLES_DONE,+ ++tups_done);
}
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, Langote_Amit_f8@lab.ntt.co.jp, rahilasyed90@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: monitoring CREATE INDEX [CONCURRENTLY]
In-Reply-To: <20190222221036.GA18589@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox