Hi Robert!

On 2019/03/23 3:31, Robert Haas wrote:
On Tue, Mar 19, 2019 at 2:47 PM Robert Haas <robertmh...@gmail.com> wrote:
how close you were getting to rewriting the entire heap.  This is the
one thing I found but did not fix; any chance you could make this
change and update the documentation to match?

Hi, is anybody working on this?

I sent this email using my personal email address: yamatattsu@gmail-.
I re-send it with the patch and my test result.

Thank you so much for reviewing the patch and sorry for the late reply.
Today, I realized that you sent the email for the patch because I took a
sick leave from work for a while. So, I created new patch based on your 
comments asap.
I hope it is acceptable to you. :)

Changes
  - Add new column *heap_tuples_written* in the view
      This column is updated when the phases are "seq scanning heap",
      "index scanning heap" or "writing new heap".
  - Fix document
  - Revised the patch on the current head: 
940311e4bb32a5fe99155052e41179c88b5d48af.

Please find attached files. :)


Regards,
Tatsuro Yamada



diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index ac2721c..26a6899 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -340,7 +340,15 @@ postgres   27093  0.0  0.0  30096  2752 ?        Ss   11:34   0:00 postgres: ser
       <entry><structname>pg_stat_progress_vacuum</structname><indexterm><primary>pg_stat_progress_vacuum</primary></indexterm></entry>
       <entry>One row for each backend (including autovacuum worker processes) running
        <command>VACUUM</command>, showing current progress.
-       See <xref linkend='vacuum-progress-reporting'/>.
+       See <xref linkend='vacuum-progress-reporting' />.
+      </entry>
+     </row>
+
+     <row>
+      <entry><structname>pg_stat_progress_cluster</structname><indexterm><primary>pg_stat_progress_cluster</primary></indexterm></entry>
+      <entry>One row for each backend running
+       <command>CLUSTER</command> or <command>VACUUM FULL</command>, showing current progress.
+       See <xref linkend='cluster-progress-reporting' />.
       </entry>
      </row>
 
@@ -3394,9 +3402,9 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
 
   <para>
    <productname>PostgreSQL</productname> has the ability to report the progress of
-   certain commands during command execution.  Currently, the only command
-   which supports progress reporting is <command>VACUUM</command>.  This may be
-   expanded in the future.
+   certain commands during command execution.  Currently, the only commands
+   which support progress reporting are <command>VACUUM</command> and
+   <command>CLUSTER</command>. This may be expanded in the future.
   </para>
 
  <sect2 id="vacuum-progress-reporting">
@@ -3408,9 +3416,11 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
    one row for each backend (including autovacuum worker processes) that is
    currently vacuuming.  The tables below describe the information
    that will be reported and provide information about how to interpret it.
-   Progress reporting is not currently supported for <command>VACUUM FULL</command>
-   and backends running <command>VACUUM FULL</command> will not be listed in this
-   view.
+   Progress for <command>VACUUM FULL</command> commands is reported via
+   <structname>pg_stat_progress_cluster</structname>
+   because both <command>VACUUM FULL</command> and <command>CLUSTER</command> 
+   rewrite the table, while regular <command>VACUUM</command> only modifies it 
+   in place. See <xref linkend='cluster-progress-reporting'/>.
   </para>
 
   <table id="pg-stat-progress-vacuum-view" xreflabel="pg_stat_progress_vacuum">
@@ -3588,6 +3598,183 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
   </table>
 
  </sect2>
+
+ <sect2 id="cluster-progress-reporting">
+  <title>CLUSTER Progress Reporting</title>
+
+  <para>
+   Whenever <command>CLUSTER</command> or <command>VACUUM FULL</command> is
+   running, the <structname>pg_stat_progress_cluster</structname> view will
+   contain a row for each backend that is currently running either command. 
+   The tables below describe the information that will be reported and
+   provide information about how to interpret it.
+  </para>
+
+  <table id="pg-stat-progress-cluster-view" xreflabel="pg_stat_progress_cluster">
+   <title><structname>pg_stat_progress_cluster</structname> View</title>
+   <tgroup cols="3">
+    <thead>
+    <row>
+      <entry>Column</entry>
+      <entry>Type</entry>
+      <entry>Description</entry>
+     </row>
+    </thead>
+
+   <tbody>
+    <row>
+     <entry><structfield>pid</structfield></entry>
+     <entry><type>integer</type></entry>
+     <entry>Process ID of backend.</entry>
+    </row>
+    <row>
+     <entry><structfield>datid</structfield></entry>
+     <entry><type>oid</type></entry>
+     <entry>OID of the database to which this backend is connected.</entry>
+    </row>
+    <row>
+     <entry><structfield>datname</structfield></entry>
+     <entry><type>name</type></entry>
+     <entry>Name of the database to which this backend is connected.</entry>
+    </row>
+    <row>
+     <entry><structfield>relid</structfield></entry>
+     <entry><type>oid</type></entry>
+     <entry>OID of the table being clustered.</entry>
+    </row>
+    <row>
+     <entry><structfield>command</structfield></entry>
+     <entry><type>text</type></entry>
+     <entry>
+       The command that is running. Either CLUSTER or VACUUM FULL.
+     </entry>
+    </row>
+    <row>
+     <entry><structfield>phase</structfield></entry>
+     <entry><type>text</type></entry>
+     <entry>
+       Current processing phase. See <xref linkend='cluster-phases' />.
+     </entry>
+    </row>
+    <row>
+     <entry><structfield>cluster_index_relid</structfield></entry>
+     <entry><type>bigint</type></entry>
+     <entry>
+       If the table is being scanned using an index, this is the OID of the
+       index being used; otherwise, it is zero.
+     </entry>
+    </row>
+    <row>
+     <entry><structfield>heap_tuples_scanned</structfield></entry>
+     <entry><type>bigint</type></entry>
+     <entry>
+       Number of heap tuples scanned.
+       This counter only advances when the phase is
+       <literal>seq scanning heap</literal>,
+       <literal>index scanning heap</literal>
+       or <literal>writing new heap</literal>.
+     </entry>
+    </row>
+    <row>
+     <entry><structfield>heap_tuples_written</structfield></entry>
+     <entry><type>bigint</type></entry>
+     <entry>
+       Number of heap tuples written.
+       This counter only advances when the phase is
+       <literal>seq scanning heap</literal>,
+       <literal>index scanning heap</literal>
+       or <literal>writing new heap</literal>.
+     </entry>
+    </row>
+    <row>
+     <entry><structfield>heap_blks_total</structfield></entry>
+     <entry><type>bigint</type></entry>
+     <entry>
+       Total number of heap blocks in the table.  This number is reported
+       as of the beginning of <literal>seq scanning heap</literal>.
+     </entry>
+    </row>
+    <row>
+     <entry><structfield>heap_blks_scanned</structfield></entry>
+     <entry><type>bigint</type></entry>
+     <entry>
+       Number of heap blocks scanned.  This counter only advances when the
+       phase is <literal>seq scanning heap</literal>.
+     </entry>
+    </row>
+    <row>
+     <entry><structfield>index_rebuild_count</structfield></entry>
+     <entry><type>bigint</type></entry>
+     <entry>
+       Number of indexes rebuilt.  This counter only advances when the phase
+       is <literal>rebuilding index</literal>.
+     </entry>
+    </row>
+   </tbody>
+   </tgroup>
+  </table>
+
+  <table id="cluster-phases">
+   <title>CLUSTER and VACUUM FULL phases</title>
+   <tgroup cols="2">
+    <thead>
+    <row>
+      <entry>Phase</entry>
+      <entry>Description</entry>
+     </row>
+    </thead>
+
+   <tbody>
+    <row>
+     <entry><literal>initializing</literal></entry>
+     <entry>
+       The command is preparing to begin scanning the heap.  This phase is
+       expected to be very brief.
+     </entry>
+    </row>
+    <row>
+     <entry><literal>seq scanning heap</literal></entry>
+     <entry>
+       The command is currently scanning the table using a sequential scan.
+     </entry>
+    </row>
+    <row>
+     <entry><literal>index scanning heap</literal></entry>
+     <entry>
+       <command>CLUSTER</command> is currently scanning the table using an index scan.
+     </entry>
+    </row>
+    <row>
+     <entry><literal>sorting tuples</literal></entry>
+     <entry>
+       <command>CLUSTER</command> is currently sorting tuples. 
+     </entry>
+    </row>
+    <row>
+     <entry><literal>swapping relation files</literal></entry>
+     <entry>
+       The command is currently swapping newly-built files into place.
+     </entry>
+    </row>
+    <row>
+     <entry><literal>rebuilding index</literal></entry>
+     <entry>
+       The command is currently rebuilding an index.
+     </entry>
+    </row>
+    <row>
+     <entry><literal>performing final cleanup</literal></entry>
+     <entry>
+       The command is performing final cleanup.  When this phase is 
+       completed, <command>CLUSTER</command>
+       or <command>VACUUM FULL</command> will end.
+     </entry>
+    </row>
+   </tbody>
+   </tgroup>
+  </table>
+
+ </sect2>
  </sect1>
 
  <sect1 id="dynamic-trace">
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index cb2c001..d2e284f 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -52,6 +52,7 @@
 #include "catalog/storage.h"
 #include "commands/tablecmds.h"
 #include "commands/event_trigger.h"
+#include "commands/progress.h"
 #include "commands/trigger.h"
 #include "executor/executor.h"
 #include "miscadmin.h"
@@ -59,6 +60,7 @@
 #include "nodes/nodeFuncs.h"
 #include "optimizer/optimizer.h"
 #include "parser/parser.h"
+#include "pgstat.h"
 #include "rewrite/rewriteManip.h"
 #include "storage/bufmgr.h"
 #include "storage/lmgr.h"
@@ -3846,6 +3848,7 @@ reindex_relation(Oid relid, int flags, int options)
 	List	   *indexIds;
 	bool		is_pg_class;
 	bool		result;
+	int			i;
 
 	/*
 	 * Open and lock the relation.  ShareLock is sufficient since we only need
@@ -3933,6 +3936,7 @@ reindex_relation(Oid relid, int flags, int options)
 
 		/* Reindex all the indexes. */
 		doneIndexes = NIL;
+		i = 1;
 		foreach(indexId, indexIds)
 		{
 			Oid			indexOid = lfirst_oid(indexId);
@@ -3950,6 +3954,11 @@ reindex_relation(Oid relid, int flags, int options)
 
 			if (is_pg_class)
 				doneIndexes = lappend_oid(doneIndexes, indexOid);
+
+			/* Set index rebuild count */
+			pgstat_progress_update_param(PROGRESS_CLUSTER_INDEX_REBUILD_COUNT,
+										 i);
+			i++;
 		}
 	}
 	PG_CATCH();
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index d962648..b89df70 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -907,6 +907,33 @@ CREATE VIEW pg_stat_progress_vacuum AS
     FROM pg_stat_get_progress_info('VACUUM') AS S
 		LEFT JOIN pg_database D ON S.datid = D.oid;
 
+CREATE VIEW pg_stat_progress_cluster AS
+    SELECT
+        S.pid AS pid,
+        S.datid AS datid,
+        D.datname AS datname,
+        S.relid AS relid,
+        CASE S.param1 WHEN 1 THEN 'CLUSTER'
+                      WHEN 2 THEN 'VACUUM FULL'
+                      END AS command,
+        CASE S.param2 WHEN 0 THEN 'initializing'
+                      WHEN 1 THEN 'seq scanning heap'
+                      WHEN 2 THEN 'index scanning heap'
+                      WHEN 3 THEN 'sorting tuples'
+                      WHEN 4 THEN 'writing new heap'
+                      WHEN 5 THEN 'swapping relation files'
+                      WHEN 6 THEN 'rebuilding index'
+                      WHEN 7 THEN 'performing final cleanup'
+                      END AS phase,
+        S.param3 AS cluster_index_relid,
+        S.param4 AS heap_tuples_scanned,
+        S.param5 AS heap_tuples_written,
+        S.param6 AS heap_blks_total,
+        S.param7 AS heap_blks_scanned,
+        S.param8 AS index_rebuild_count
+    FROM pg_stat_get_progress_info('CLUSTER') AS S
+        LEFT JOIN pg_database D ON S.datid = D.oid;
+
 CREATE VIEW pg_user_mappings AS
     SELECT
         U.oid       AS umid,
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 3e2a807..205070b 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -36,10 +36,12 @@
 #include "catalog/objectaccess.h"
 #include "catalog/toasting.h"
 #include "commands/cluster.h"
+#include "commands/progress.h"
 #include "commands/tablecmds.h"
 #include "commands/vacuum.h"
 #include "miscadmin.h"
 #include "optimizer/optimizer.h"
+#include "pgstat.h"
 #include "storage/bufmgr.h"
 #include "storage/lmgr.h"
 #include "storage/predicate.h"
@@ -276,6 +278,14 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 	/* Check for user-requested abort. */
 	CHECK_FOR_INTERRUPTS();
 
+	pgstat_progress_start_command(PROGRESS_COMMAND_CLUSTER, tableOid);
+	if (OidIsValid(indexOid))
+		pgstat_progress_update_param(PROGRESS_CLUSTER_COMMAND,
+									 PROGRESS_CLUSTER_COMMAND_CLUSTER);
+	else
+		pgstat_progress_update_param(PROGRESS_CLUSTER_COMMAND,
+									 PROGRESS_CLUSTER_COMMAND_VACUUM_FULL);
+
 	/*
 	 * We grab exclusive access to the target rel and index for the duration
 	 * of the transaction.  (This is redundant for the single-transaction
@@ -286,7 +296,10 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 
 	/* If the table has gone away, we can skip processing it */
 	if (!OldHeap)
+	{
+		pgstat_progress_end_command();
 		return;
+	}
 
 	/*
 	 * Since we may open a new transaction for each relation, we have to check
@@ -305,6 +318,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 		if (!pg_class_ownercheck(tableOid, GetUserId()))
 		{
 			relation_close(OldHeap, AccessExclusiveLock);
+			pgstat_progress_end_command();
 			return;
 		}
 
@@ -319,6 +333,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 		if (RELATION_IS_OTHER_TEMP(OldHeap))
 		{
 			relation_close(OldHeap, AccessExclusiveLock);
+			pgstat_progress_end_command();
 			return;
 		}
 
@@ -330,6 +345,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 			if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(indexOid)))
 			{
 				relation_close(OldHeap, AccessExclusiveLock);
+				pgstat_progress_end_command();
 				return;
 			}
 
@@ -340,6 +356,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 			if (!HeapTupleIsValid(tuple))	/* probably can't happen */
 			{
 				relation_close(OldHeap, AccessExclusiveLock);
+				pgstat_progress_end_command();
 				return;
 			}
 			indexForm = (Form_pg_index) GETSTRUCT(tuple);
@@ -347,6 +364,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 			{
 				ReleaseSysCache(tuple);
 				relation_close(OldHeap, AccessExclusiveLock);
+				pgstat_progress_end_command();
 				return;
 			}
 			ReleaseSysCache(tuple);
@@ -401,6 +419,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 		!RelationIsPopulated(OldHeap))
 	{
 		relation_close(OldHeap, AccessExclusiveLock);
+		pgstat_progress_end_command();
 		return;
 	}
 
@@ -416,6 +435,8 @@ cluster_rel(Oid tableOid, Oid indexOid, int options)
 	rebuild_relation(OldHeap, indexOid, verbose);
 
 	/* NB: rebuild_relation does table_close() on OldHeap */
+
+	pgstat_progress_end_command();
 }
 
 /*
@@ -928,6 +949,17 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
 	 */
 	if (OldIndex != NULL && !use_sort)
 	{
+		const int   ci_index[] = {
+			PROGRESS_CLUSTER_PHASE,
+			PROGRESS_CLUSTER_INDEX_RELID
+		};
+		int64       ci_val[2];
+
+		/* Set phase and OIDOldIndex to columns */
+		ci_val[0] = PROGRESS_CLUSTER_PHASE_INDEX_SCAN_HEAP;
+		ci_val[1] = OIDOldIndex;
+		pgstat_progress_update_multi_param(2, ci_index, ci_val);
+
 		tableScan = NULL;
 		heapScan = NULL;
 		indexScan = index_beginscan(OldHeap, OldIndex, SnapshotAny, 0, 0);
@@ -935,9 +967,17 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
 	}
 	else
 	{
+		/* In scan-and-sort mode and also VACUUM FULL, set phase */
+		pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE,
+									 PROGRESS_CLUSTER_PHASE_SEQ_SCAN_HEAP);
+
 		tableScan = table_beginscan(OldHeap, SnapshotAny, 0, (ScanKey) NULL);
 		heapScan = (HeapScanDesc) tableScan;
 		indexScan = NULL;
+
+		/* Set total heap blocks */
+		pgstat_progress_update_param(PROGRESS_CLUSTER_TOTAL_HEAP_BLKS,
+									 heapScan->rs_nblocks);
 	}
 
 	slot = table_slot_create(OldHeap, NULL);
@@ -994,6 +1034,10 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
 				break;
 
 			buf = heapScan->rs_cbuf;
+
+			/* In scan-and-sort mode and also VACUUM FULL, set heap blocks scanned */
+			pgstat_progress_update_param(PROGRESS_CLUSTER_HEAP_BLKS_SCANNED,
+										 heapScan->rs_cblock + 1);
 		}
 
 		LockBuffer(buf, BUFFER_LOCK_SHARE);
@@ -1064,12 +1108,31 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
 
 		num_tuples += 1;
 		if (tuplesort != NULL)
+		{
 			tuplesort_putheaptuple(tuplesort, tuple);
+
+			/* In scan-and-sort mode, report increase in number of tuples scanned */
+			pgstat_progress_update_param(PROGRESS_CLUSTER_HEAP_TUPLES_SCANNED,
+										 num_tuples);
+		}
 		else
+		{
+			const int   ct_index[] = {
+				PROGRESS_CLUSTER_HEAP_TUPLES_SCANNED,
+				PROGRESS_CLUSTER_HEAP_TUPLES_WRITTEN
+			};
+			int64       ct_val[2];
+
 			reform_and_rewrite_tuple(tuple,
 									 oldTupDesc, newTupDesc,
 									 values, isnull,
 									 rwstate);
+
+			/* In indexscan mode and also VACUUM FULL, report increase in number of tuples scanned and written */
+			ct_val[0] = num_tuples;
+			ct_val[1] = num_tuples;
+			pgstat_progress_update_multi_param(2, ct_index, ct_val);
+		}
 	}
 
 	if (indexScan != NULL)
@@ -1085,8 +1148,17 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
 	 */
 	if (tuplesort != NULL)
 	{
+		double n_tuples = 0;
+		/* Report that we are now sorting tuples */
+		pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE,
+									 PROGRESS_CLUSTER_PHASE_SORT_TUPLES);
+
 		tuplesort_performsort(tuplesort);
 
+		/* Report that we are now writing new heap */
+		pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE,
+									 PROGRESS_CLUSTER_PHASE_WRITE_NEW_HEAP);
+
 		for (;;)
 		{
 			HeapTuple	tuple;
@@ -1097,10 +1169,14 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
 			if (tuple == NULL)
 				break;
 
+			n_tuples += 1;
 			reform_and_rewrite_tuple(tuple,
 									 oldTupDesc, newTupDesc,
 									 values, isnull,
 									 rwstate);
+			/* Report n_tuples */
+			pgstat_progress_update_param(PROGRESS_CLUSTER_HEAP_TUPLES_WRITTEN,
+										 n_tuples);
 		}
 
 		tuplesort_end(tuplesort);
@@ -1539,6 +1615,10 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
 	int			reindex_flags;
 	int			i;
 
+	/* Report that we are now swapping relation files */
+	pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE,
+								 PROGRESS_CLUSTER_PHASE_SWAP_REL_FILES);
+
 	/* Zero out possible results from swapped_relation_files */
 	memset(mapped_tables, 0, sizeof(mapped_tables));
 
@@ -1586,8 +1666,16 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
 	else if (newrelpersistence == RELPERSISTENCE_PERMANENT)
 		reindex_flags |= REINDEX_REL_FORCE_INDEXES_PERMANENT;
 
+	/* Report that we are now reindexing relations */
+	pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE,
+								 PROGRESS_CLUSTER_PHASE_REBUILD_INDEX);
+
 	reindex_relation(OIDOldHeap, reindex_flags, 0);
 
+	/* Report that we are now doing clean up */
+	pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE,
+								 PROGRESS_CLUSTER_PHASE_FINAL_CLEANUP);
+
 	/*
 	 * If the relation being rebuild is pg_class, swap_relation_files()
 	 * couldn't update pg_class's own pg_class entry (check comments in
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index da1d685..90a817a 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -468,6 +468,8 @@ pg_stat_get_progress_info(PG_FUNCTION_ARGS)
 	/* Translate command name into command type code. */
 	if (pg_strcasecmp(cmd, "VACUUM") == 0)
 		cmdtype = PROGRESS_COMMAND_VACUUM;
+	else if (pg_strcasecmp(cmd, "CLUSTER") == 0)
+		cmdtype = PROGRESS_COMMAND_CLUSTER;
 	else
 		ereport(ERROR,
 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
diff --git a/src/include/commands/progress.h b/src/include/commands/progress.h
index 9858b36..04542d9 100644
--- a/src/include/commands/progress.h
+++ b/src/include/commands/progress.h
@@ -34,4 +34,27 @@
 #define PROGRESS_VACUUM_PHASE_TRUNCATE			5
 #define PROGRESS_VACUUM_PHASE_FINAL_CLEANUP		6
 
+/* Progress parameters for cluster */
+#define PROGRESS_CLUSTER_COMMAND				0
+#define PROGRESS_CLUSTER_PHASE					1
+#define PROGRESS_CLUSTER_INDEX_RELID			2
+#define PROGRESS_CLUSTER_HEAP_TUPLES_SCANNED	3
+#define PROGRESS_CLUSTER_HEAP_TUPLES_WRITTEN	4
+#define PROGRESS_CLUSTER_TOTAL_HEAP_BLKS		5
+#define PROGRESS_CLUSTER_HEAP_BLKS_SCANNED		6
+#define PROGRESS_CLUSTER_INDEX_REBUILD_COUNT	7
+
+/* Phases of cluster (as dvertised via PROGRESS_CLUSTER_PHASE) */
+#define PROGRESS_CLUSTER_PHASE_SEQ_SCAN_HEAP	1
+#define PROGRESS_CLUSTER_PHASE_INDEX_SCAN_HEAP	2
+#define PROGRESS_CLUSTER_PHASE_SORT_TUPLES		3
+#define PROGRESS_CLUSTER_PHASE_WRITE_NEW_HEAP	4
+#define PROGRESS_CLUSTER_PHASE_SWAP_REL_FILES	5
+#define PROGRESS_CLUSTER_PHASE_REBUILD_INDEX	6
+#define PROGRESS_CLUSTER_PHASE_FINAL_CLEANUP	7
+
+/* Commands of PROGRESS_CLUSTER */
+#define PROGRESS_CLUSTER_COMMAND_CLUSTER		1
+#define PROGRESS_CLUSTER_COMMAND_VACUUM_FULL	2
+
 #endif
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index ea6cc8b..c080fa6 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -950,7 +950,8 @@ typedef enum
 typedef enum ProgressCommandType
 {
 	PROGRESS_COMMAND_INVALID,
-	PROGRESS_COMMAND_VACUUM
+	PROGRESS_COMMAND_VACUUM,
+	PROGRESS_COMMAND_CLUSTER
 } ProgressCommandType;
 
 #define PGSTAT_NUM_PROGRESS_PARAM	10
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index f104dc4..49ca3be 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1830,6 +1830,34 @@ pg_stat_database_conflicts| SELECT d.oid AS datid,
     pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin,
     pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock
    FROM pg_database d;
+pg_stat_progress_cluster| SELECT s.pid,
+    s.datid,
+    d.datname,
+    s.relid,
+        CASE s.param1
+            WHEN 1 THEN 'CLUSTER'::text
+            WHEN 2 THEN 'VACUUM FULL'::text
+            ELSE NULL::text
+        END AS command,
+        CASE s.param2
+            WHEN 0 THEN 'initializing'::text
+            WHEN 1 THEN 'seq scanning heap'::text
+            WHEN 2 THEN 'index scanning heap'::text
+            WHEN 3 THEN 'sorting tuples'::text
+            WHEN 4 THEN 'writing new heap'::text
+            WHEN 5 THEN 'swapping relation files'::text
+            WHEN 6 THEN 'rebuilding index'::text
+            WHEN 7 THEN 'performing final cleanup'::text
+            ELSE NULL::text
+        END AS phase,
+    s.param3 AS cluster_index_relid,
+    s.param4 AS heap_tuples_scanned,
+    s.param5 AS heap_tuples_written,
+    s.param6 AS heap_blks_total,
+    s.param7 AS heap_blks_scanned,
+    s.param8 AS index_rebuild_count
+   FROM (pg_stat_get_progress_info('CLUSTER'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10)
+     LEFT JOIN pg_database d ON ((s.datid = d.oid)));
 pg_stat_progress_vacuum| SELECT s.pid,
     s.datid,
     d.datname,
[View definition]
# \d pg_stat_progress_cluster
           View "pg_catalog.pg_stat_progress_cluster"
       Column        |  Type   | Collation | Nullable | Default
---------------------+---------+-----------+----------+---------
 pid                 | integer |           |          |
 datid               | oid     |           |          |
 datname             | name    |           |          |
 relid               | oid     |           |          |
 command             | text    |           |          |
 phase               | text    |           |          |
 cluster_index_relid | bigint  |           |          |
 heap_tuples_scanned | bigint  |           |          |
 heap_tuples_written | bigint  |           |          |
 heap_blks_total     | bigint  |           |          |
 heap_blks_scanned   | bigint  |           |          |
 index_rebuild_count | bigint  |           |          |


[Select command for the view]
# \a \t
Output format is unaligned.
Tuples only is on.

# select * from pg_stat_progress_cluster; \watch 0.05


[Tests]
# -- index scan
# set enable_seqscan to off;
SET
# cluster verbose t1 using idx_t1;
INFO:  clustering "public.t1" using index scan on "idx_t1"
INFO:  "t1": found 0 removable, 1000000 nonremovable row versions in 5406 pages
DETAIL:  0 dead row versions cannot be removed yet.
CPU: user: 0.50 s, system: 0.09 s, elapsed: 1.11 s.
CLUSTER
===============================================================================
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|9023|9023|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|81618|81618|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|169940|169940|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|272053|272053|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|390683|390683|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|420875|420875|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|421060|421060|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|421060|421060|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|456829|456829|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|532482|532482|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|624477|624477|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|736803|736803|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|782735|782735|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|797720|797720|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|797720|797720|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|838803|838803|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|919820|919820|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning heap|16387|959595|959595|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning 
heap|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning 
heap|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning 
heap|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|index scanning 
heap|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|0
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
14228|13570|postgres|16384|CLUSTER|rebuilding index|16387|1000000|1000000|0|0|1
===============================================================================


# -- seq scan
# set enable_seqscan to on;
SET
# set enable_indexscan to off;
SET
# cluster verbose t1 using idx_t1;
INFO:  clustering "public.t1" using sequential scan and sort
INFO:  "t1": found 0 removable, 1000000 nonremovable row versions in 5406 pages
DETAIL:  0 dead row versions cannot be removed yet.
CPU: user: 0.51 s, system: 0.18 s, elapsed: 1.21 s.
CLUSTER
===============================================================================
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|51037|0|5406|276|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|238724|0|5406|1291|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|417950|0|5406|2260|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|599185|0|5406|3239|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|600548|0|5406|3247|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|954529|0|5406|5160|0
14228|13570|postgres|16384|CLUSTER|sorting tuples|0|1000000|0|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|189050|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|387020|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|387205|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|387205|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|387390|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|508831|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|648083|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|763680|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|763865|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|763865|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|768120|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|892600|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
===============================================================================


# -- only given table name to cluster command
# cluster verbose t1;
INFO:  clustering "public.t1" using sequential scan and sort
INFO:  "t1": found 0 removable, 1000000 nonremovable row versions in 5406 pages
DETAIL:  0 dead row versions cannot be removed yet.
CPU: user: 0.52 s, system: 0.13 s, elapsed: 1.18 s.
CLUSTER
===============================================================================
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|73057|0|5406|395|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|273190|0|5406|1477|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|509770|0|5406|2756|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|599185|0|5406|3239|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|707260|0|5406|3824|0
14228|13570|postgres|16384|CLUSTER|sorting tuples|0|1000000|0|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|46744|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|282262|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|353165|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|353350|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|353350|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|428761|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|571114|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|729825|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|729825|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|730010|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|730195|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|832310|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|985576|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
===============================================================================


# -- only cluster command
# cluster verbose;
INFO:  clustering "public.t1" using sequential scan and sort
INFO:  "t1": found 0 removable, 1000000 nonremovable row versions in 5406 pages
DETAIL:  0 dead row versions cannot be removed yet.
CPU: user: 0.56 s, system: 0.15 s, elapsed: 1.23 s.
CLUSTER
===============================================================================
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|74763|0|5406|405|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|281351|0|5406|1521|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|524287|0|5406|2834|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|599185|0|5406|3239|0
14228|13570|postgres|16384|CLUSTER|seq scanning heap|0|763132|0|5406|4126|0
14228|13570|postgres|16384|CLUSTER|sorting tuples|0|1000000|0|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|66356|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|294150|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|319495|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|319495|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|357605|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|483841|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|540570|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|595703|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|695970|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|696155|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|696155|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|760065|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new heap|0|1000000|888783|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|writing new 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|CLUSTER|rebuilding 
index|0|1000000|1000000|5406|5406|1
===============================================================================


# -- vacuum full
# vacuum full verbose t1;
INFO:  vacuuming "public.t1"
INFO:  "t1": found 0 removable, 1000000 nonremovable row versions in 5406 pages
DETAIL:  0 dead row versions cannot be removed yet.
CPU: user: 0.33 s, system: 0.07 s, elapsed: 0.78 s.
VACUUM
===============================================================================
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|24565|24565|5406|133|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|134760|134760|5406|729|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|250860|250860|5406|1357|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|299909|299909|5406|1622|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|375735|375735|5406|2032|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|421042|421042|5406|2276|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|538172|538172|5406|2910|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|627520|627520|5406|3393|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|688376|688376|5406|3721|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|742035|742035|5406|4012|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|819181|819181|5406|4429|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|939170|939170|5406|5077|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1


# -- vacuum full
# vacuum full;
VACUUM
===============================================================================
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|102107|102107|5406|552|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|231435|231435|5406|1252|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|288957|288957|5406|1562|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|446546|446546|5406|2414|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|449550|449550|5406|2431|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|573284|573284|5406|3099|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|650309|650309|5406|3516|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|755356|755356|5406|4084|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|888000|888000|5406|4801|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|893550|893550|5406|4831|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|980371|980371|5406|5300|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|seq scanning 
heap|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|0
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|16384|VACUUM FULL|rebuilding 
index|0|1000000|1000000|5406|5406|1
14228|13570|postgres|2613|VACUUM FULL|seq scanning heap|0|0|0|0|0|0
14228|13570|postgres|1255|VACUUM FULL|initializing|0|0|0|0|0|0
14228|13570|postgres|2604|VACUUM FULL|initializing|0|0|0|0|0|0
14228|13570|postgres|2617|VACUUM FULL|initializing|0|0|0|0|0|0
14228|13570|postgres|2602|VACUUM FULL|seq scanning heap|0|711|711|6|6|0
14228|13570|postgres|2600|VACUUM FULL|initializing|0|0|0|0|0|0
14228|13570|postgres|2618|VACUUM FULL|performing final cleanup|0|122|122|12|12|2
14228|13570|postgres|2964|VACUUM FULL|initializing|0|0|0|0|0|0
14228|13570|postgres|1261|VACUUM FULL|seq scanning heap|0|3|3|1|1|0
14228|13570|postgres|3603|VACUUM FULL|seq scanning heap|0|418|418|3|3|0
14228|13570|postgres|3079|VACUUM FULL|rebuilding index|0|1|1|1|1|1
14228|13570|postgres|3456|VACUUM FULL|seq scanning heap|0|96|96|29|4|0
14228|13570|postgres|6104|VACUUM FULL|rebuilding index|0|0|0|0|0|0
14228|13570|postgres|13415|VACUUM FULL|initializing|0|0|0|0|0|0
===============================================================================

Reply via email to