Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gxJ2S-0001YP-MU for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Feb 2019 22:11:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gxJ2O-0001vt-Sw for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Feb 2019 22:11:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gxJ2O-0001vm-Ln for pgsql-hackers@lists.postgresql.org; Fri, 22 Feb 2019 22:11:20 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gxJ2L-0007rB-Hs for pgsql-hackers@lists.postgresql.org; Fri, 22 Feb 2019 22:11:19 +0000 Received: by mail-qt1-x841.google.com with SMTP id z25so4272310qti.13 for ; Fri, 22 Feb 2019 14:11:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=/j7X9EustPh1RGN7iUiyDaUNGnvUiuSlNPNs2Ib5WJA=; b=i/AQqLdZIk07IjlgK55glWyV0p5SluC5APQ1r+C1U676QVt1jTOxDkbR84oB1TuvlS yoVp3MHhC4/K6O9aC55yeXLHGCkcHfOsT1SCuKEzlJkbaf/s9J2ObZqerPol8yqLNBTw tZxBDZFtCeC9FAyix6K9f74WqRClZkpOEepuyMUC8/HxoTmZUg69MNtzyTbUPPAcMWP6 WnzNmHmp4iW2dBa9+PTpexg6sOo0WtuNqIcFEzN1/Z9pfOiuCLdbDlipelcyxJ+lJ1C2 zik/zLDEE7nk47QE3QBPvc73GIID3RtGiFipK2Ym2igt5lgQPHq5gTEh0QS6I37VL22l 8Bzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=/j7X9EustPh1RGN7iUiyDaUNGnvUiuSlNPNs2Ib5WJA=; b=LJJXkch7DDFE2jOb6qRTVup7dIC0/QsbKmvdYwxzGVlg+hqS4WH49VbgbTqakQQvBV Z1AjBkU4STZDk6MiSuXNYCYwY85r6q+jONY8J9LGJ8pH/ECn53NMM0dYoPNc+4kFYJSt RUoRFKxkNbsWepmtkGBdrrdpYnu9f3w7JCo57pl91OBuW5w36ssAD4wXn6F4NQ7baySF 2BgKwRF4oA+O7GrGtEoEuzKpj/zqgfY9D8DeCo/AqCn1GTSV9oWHX0Loz36m/NECmpYR 0evHexDEP9sLM7CdHnFZ9MANmG2mMwHZ+pGcL9jIU6o3Tk6uHAfQETI7BqrnXo+gX5hb ZKcQ== X-Gm-Message-State: AHQUAuYMYAQzgkaIQ1r3Ak9RohwOHhCEGHgOelfkd4bx8mMmYfcoJgOI /UvX+u3W4SQvDxDTTIt7R9AmhA== X-Google-Smtp-Source: AHgI3IZ+w7YBax3MuNPWyTlvNB4lFXYxFi0SxOljBmVMDEKMvHGBx3PQLFdMiuA03pfS/DBX1wXiKw== X-Received: by 2002:a0c:b6d2:: with SMTP id h18mr4974038qve.216.1550873475725; Fri, 22 Feb 2019 14:11:15 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([191.125.99.205]) by smtp.gmail.com with ESMTPSA id p5sm1831222qti.42.2019.02.22.14.11.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 14:11:13 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 94DFF124744; Fri, 22 Feb 2019 19:10:36 -0300 (-03) Date: Fri, 22 Feb 2019 19:10:36 -0300 From: Alvaro Herrera To: Amit Langote Cc: Rahila Syed , Pg Hackers Subject: Re: monitoring CREATE INDEX [CONCURRENTLY] Message-ID: <20190222221036.GA18589@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190222215423.GA16912@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --/04w6evG8XlLl3ft Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 --/04w6evG8XlLl3ft Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="progress-hash.patch" diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 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.c index 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); } } --/04w6evG8XlLl3ft--