Re: Add command column to pg_stat_progress_create_index

2019-06-04 Thread Peter Eisentraut
On 2019-05-27 20:18, Peter Eisentraut wrote:
> I propose to add a column "command" to pg_stat_progress_create_index.
> The sibling view pg_stat_progress_cluster already contains such a
> column.  This can help distinguish which command is running and thus
> which phases to expect.  It seems reasonable to keep these views
> consistent, too.  (They are both new in PG12.)  Patch attached.

committed

-- 
Peter Eisentraut  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




Re: Add command column to pg_stat_progress_create_index

2019-05-28 Thread David Fetter
On Mon, May 27, 2019 at 11:20:28AM -0700, Andres Freund wrote:
> Hi,
> 
> On 2019-05-27 14:18:12 -0400, Peter Eisentraut wrote:
> > I propose to add a column "command" to pg_stat_progress_create_index.
> > The sibling view pg_stat_progress_cluster already contains such a
> > column.  This can help distinguish which command is running and thus
> > which phases to expect.  It seems reasonable to keep these views
> > consistent, too.  (They are both new in PG12.)  Patch attached.
> 
> Seems like we should do that for v12 then?

+1

Best,
David.
-- 
David Fetter  http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate




Re: Add command column to pg_stat_progress_create_index

2019-05-28 Thread Michael Paquier
On Mon, May 27, 2019 at 11:20:28AM -0700, Andres Freund wrote:
> On 2019-05-27 14:18:12 -0400, Peter Eisentraut wrote:
>> I propose to add a column "command" to pg_stat_progress_create_index.
>> The sibling view pg_stat_progress_cluster already contains such a
>> column.  This can help distinguish which command is running and thus
>> which phases to expect.  It seems reasonable to keep these views
>> consistent, too.  (They are both new in PG12.)  Patch attached.
> 
> Seems like we should do that for v12 then?

+1.
--
Michael


signature.asc
Description: PGP signature


Re: Add command column to pg_stat_progress_create_index

2019-05-27 Thread Fabrízio de Royes Mello
On Mon, May 27, 2019 at 4:51 PM Alvaro Herrera 
wrote:
>
> On 2019-May-27, Peter Eisentraut wrote:
>
> > I propose to add a column "command" to pg_stat_progress_create_index.
> > The sibling view pg_stat_progress_cluster already contains such a
> > column.  This can help distinguish which command is running and thus
> > which phases to expect.  It seems reasonable to keep these views
> > consistent, too.  (They are both new in PG12.)  Patch attached.
>
> +1.
>

+1

--
   Fabrízio de Royes Mello Timbira - http://www.timbira.com.br/
   PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento


Re: Add command column to pg_stat_progress_create_index

2019-05-27 Thread Alvaro Herrera
On 2019-May-27, Peter Eisentraut wrote:

> I propose to add a column "command" to pg_stat_progress_create_index.
> The sibling view pg_stat_progress_cluster already contains such a
> column.  This can help distinguish which command is running and thus
> which phases to expect.  It seems reasonable to keep these views
> consistent, too.  (They are both new in PG12.)  Patch attached.

+1.

-- 
Álvaro Herrerahttps://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




Re: Add command column to pg_stat_progress_create_index

2019-05-27 Thread Andres Freund
Hi,

On 2019-05-27 14:18:12 -0400, Peter Eisentraut wrote:
> I propose to add a column "command" to pg_stat_progress_create_index.
> The sibling view pg_stat_progress_cluster already contains such a
> column.  This can help distinguish which command is running and thus
> which phases to expect.  It seems reasonable to keep these views
> consistent, too.  (They are both new in PG12.)  Patch attached.

Seems like we should do that for v12 then?

Greetings,

Andres Freund




Add command column to pg_stat_progress_create_index

2019-05-27 Thread Peter Eisentraut
I propose to add a column "command" to pg_stat_progress_create_index.
The sibling view pg_stat_progress_cluster already contains such a
column.  This can help distinguish which command is running and thus
which phases to expect.  It seems reasonable to keep these views
consistent, too.  (They are both new in PG12.)  Patch attached.

-- 
Peter Eisentraut  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From aa08a89ef9d99d0af2b22566626be2b13f09e292 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut 
Date: Mon, 27 May 2019 14:06:17 -0400
Subject: [PATCH] Add command column to pg_stat_progress_create_index

This allows determining which command is running, similar to
pg_stat_progress_cluster.
---
 doc/src/sgml/monitoring.sgml | 11 ++-
 src/backend/catalog/index.c  |  2 ++
 src/backend/catalog/system_views.sql |  5 +
 src/backend/commands/indexcmds.c |  8 
 src/include/commands/progress.h  |  7 +++
 src/test/regress/expected/rules.out  |  7 +++
 6 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index 570ac5e06f..bf72d0c303 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -3534,6 +3534,15 @@ 
pg_stat_progress_create_index View
   OID of the index being created or reindexed.  During a
   non-concurrent CREATE INDEX, this is 0.
  
+ 
+  command
+  text
+  
+   The command that is running: CREATE INDEX,
+   CREATE INDEX CONCURRENTLY,
+   REINDEX, or REINDEX CONCURRENTLY.
+  
+ 
  
   phase
   text
@@ -3965,7 +3974,7 @@ pg_stat_progress_cluster 
View
  command
  text
  
-   The command that is running. Either CLUSTER or VACUUM FULL.
+  The command that is running. Either CLUSTER or 
VACUUM FULL.
  
 
 
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 50c8bb9ce6..d2e4f53a80 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -3278,6 +3278,8 @@ reindex_index(Oid indexId, bool skip_constraint_checks, 
char persistence,
 
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);
 
diff --git a/src/backend/catalog/system_views.sql 
b/src/backend/catalog/system_views.sql
index 52a6c31584..78a103cdb9 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -956,6 +956,11 @@ CREATE VIEW pg_stat_progress_create_index AS
 S.pid AS pid, S.datid AS datid, D.datname AS datname,
 S.relid AS relid,
 CAST(S.param7 AS oid) AS index_relid,
+CASE S.param1 WHEN 1 THEN 'CREATE INDEX'
+  WHEN 2 THEN 'CREATE INDEX CONCURRENTLY'
+  WHEN 3 THEN 'REINDEX'
+  WHEN 4 THEN 'REINDEX CONCURRENTLY'
+  END AS command,
 CASE S.param10 WHEN 0 THEN 'initializing'
WHEN 1 THEN 'waiting for writers before build'
WHEN 2 THEN 'building index' ||
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 40ea629ffe..4d76da8293 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -498,8 +498,14 @@ DefineIndex(Oid relationId,
 * done.
 */
if (!OidIsValid(parentIndexId))
+   {
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
  
relationId);
+   pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
+
stmt->concurrent ?
+
PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY :
+
PROGRESS_CREATEIDX_COMMAND_CREATE);
+   }
 
/*
 * No index OID to report yet
@@ -2923,6 +2929,8 @@ ReindexRelationConcurrently(Oid relationOid, int options)
 
pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
  
RelationGetRelid(heapRel));
+   pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
+
PROGRESS_CREATEIDX_COMMAND_REINDEX_C